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.
You passed 0 in for the initial value. Is this required? In my solution, I omitted the 0 and it worked well; can you explain where omitting the 0 could cause a problem?
Thanks for sharing your insight!
Did some research on how you used the underscore in the callback function. The callback function is provided an 'index', 'element' and 'array object' parameter values. Per my research, some developers use the underscore to store the value, though essentially say it's not going to be used. Is this correct, or is there some other reason why you're using the underscore? (Wouldn't it be easier to omit the underscore?) Thanks!