Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Yes,
forEach
would be more appropriate in this instance as the iteration doesn't need to return anything.Yeah. He isn't storing or using the array
.map
creates. Just iterating over it to conditionally incrementi
. So that's why I asked why he used.map
and not.forEach
forEach: This iterates over a list and applies some operation with side effects to each list member (example: saving every list item to the database)
map: This iterates over a list, transforms each member of that list, and returns another list of the same size with the transformed members (example: transforming list of strings to uppercase)
ref: https://stackoverflow.com/questions/34426458/javascript-difference-between-foreach-and-map
Why
.map
and not.forEach
?