3 ms·
If the correct answer was [123, 456, NaN...] then it would actually be a good question for the reasons you bring up. The thing that makes it a trick question i
by reificator 9y ago
If the correct answer was [123, 456, NaN...] then it would actually be a good question for the reasons you bring up.
The thing that makes it a trick question is that map calls the given function with the value, the index, and the original array. And parseInt takes a value and a radix. Which means your 4th entry is parsed in base 4, your 8th is parsed in base 8, etc....
So the correct answer is [123, NaN, NaN...], and that makes it a trick question.