i am working on exercise: Squared concatenation of a Number in JavaScript (https://www.tutorialspoint.com/squared-concatenation-of-a-number-in-javascript). I am trying to add it to a function so it looks like:
function squareDigits(num){
const squared = num => {
const numStr = String(num);
let res = '';
for(let i = 0; i < numStr.length; i++){
const square = Math.pow(+numStr[i], 2);
res += square;
};
return res;
};
}
console.log(squareDigits(9191));
But it keeps returning undefined, not sure why. Any help would be appreciated thanks