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.
Don't you see that the fork has failed tests when using your suggestion? The code is raising an error if the array is empty. So, yes, that
0
is absolutely necessary if you want the code to be actually correct.why?
wrong
Using an initial value is unnecessarry since it's zero.
This leads to an extra circle through the array which is not needed here.
If you omit the initial value you will therefore save one circle.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#how_reduce_works_without_an_initial_value