Map + Callback Function with Optional Args = 🙀
Yet another JavaScript pitfall.
I have encountered this uncanny behavior of JavaScript. Long story short, when you pass to a map()
a callback function with optional parameters, those parameters are bound to be filled with the current element's index (and the original array if the callback function can take 3 arguments in total). So, be explicit about what you intend to pass to the callback function.