0

I saw someone wrote an arrow function in a way that I have never seen before.

function reverseArr(num) {
return String(num)
.split("")
.reverse()
.map(x => +x);
}

console.log(reverseArr(1234)); // [4, 3, 2, 1]

What does the +x do to the array? When I removed the + sign, I got an array of string instead.

// ["4", "3", "2", "1"]
Fitri Rozi
  • 43
  • 6

0 Answers0