Ad

Given a number, this function squares every digit and concatenates the results.
Example: 9119 → 811181 (because 9²=81, 1²=1, 1²=1, 9²=81).

function squareDigits(num) {
  return Number(
    num
      .toString()
      .split('')
      .map(d => (d * d).toString())
      .join('')
  );
}