Question 7
Back to Exercise
Why does ["10", "10", "10"].map(parseInt) return [10, NaN, 2]?
- A parseInt cannot be used as a callback
- B The strings are parsed as octal
- C map passes the index as parseInt's second argument (radix): radix 0 → decimal, radix 1 → invalid, radix 2 → binary Correct
- D It is a browser bug
Correct Answer: Option C
parseInt("10", 0) uses base 10, parseInt("10", 1) is NaN, and parseInt("10", 2) reads binary 10 = 2. Use .map(Number) or .map((s) => parseInt(s, 10)).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!