Question 9
Back to Exercise
arr.flatMap(fn) is equivalent to which expression?
- A arr.flat().map(fn)
- B arr.map(fn).flat(1) Correct
- C arr.map(fn).flat(Infinity)
- D arr.filter(fn).flat()
Correct Answer: Option B
flatMap maps first and then flattens exactly one level, in a single efficient pass.
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!