Consider this extract from a function for squaring every digit:
const result = num.toString().split('').map(Number).map(n => n * n);
In this when I use parseInt
in the map()
instead of Number
, the second element in the array (with index 1) always gets the value NaN
but Number
works perfectly fine. I read the docs but still didn't get it. Can anyone tell why this happens?