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.
Thanks you. But I do not understand why 0 at the end is taken as the initial value or why and empty array causes an error you wont pass with "type checking" number == []
Very old chain, but for new readers: if you don't pass the 0 at the end, the first value of your array will be taken as the initial value of the accumulator and won't be modified by the (n*n) part.
If an initial value is provided to the reduce method, the first argument is the initial value and the second argument is the value of the first (!) element in the array.
If an initial value is not provided, the first argument is the value of the first element in the array and the second argument is the value of the second (!) element in the array.
And it removes the need to square only the first element in the array passed to reduce as first previous value.
It would cause a problem with an empty list.