There is no issue with that code. It's just two examples. The first is used with flatMap()
flatMap()
const myAwesomeArray = [[1], [2], [3], [4], [5]] myAwesomeArray.flatMap(arr => arr * 10) //-------> Output : [10, 20, 30, 40, 50]
And the second uses flat() and map().
flat()
map()
const myAwesomeArray = [[1], [2], [3], [4], [5]] // With .map() and .flat() myAwesomeArray.map(arr => arr * 10).flat() //-------> Output : [10, 20, 30, 40, 50]
As a side note, with flatMap(), the map() function is applied first and flat() comes after.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There is no issue with that code. It's just two examples.
The first is used with
flatMap()
And the second uses
flat()
andmap()
.As a side note, with
flatMap()
, themap()
function is applied first andflat()
comes after.