-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Welcome. In this kata, you are asked to square every digit of a number and concatenate them.
For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1.
Note: The function accepts an integer and returns an integer
function squareDigits(num){
if (!Number.isInteger(num)) {
return new Error('Only supports integers')
}
return Number(
Array
.from(String(num))
.map(n => n * n)
.join('')
)
}
https://www.codewars.com/kata/546e2562b03326a88e000020/train/javascript
Metadata
Metadata
Assignees
Labels
No labels