Question 19
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
["a", "b"]
.map((v, i) => [i, v])
.forEach(([i, v]) => console.log(i + v));
- A 1 1
- B a0 b1
- C 0 1
- D 0a 1b Correct
Correct Answer: Option D
map builds [index, value] pairs and forEach destructures each pair in its parameter list. 0 + "a" concatenates.
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!