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.
I was thinking the same thing... I think that it's because: "Your reducer function's returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array, and ultimately becomes the final, single resulting value." So, even though
prev
is never explictly reassigned, each time it hitsreturn
whatever is returned there is assigned toprev
for the next time it iterates through the array.Oh, never mind. I see that there is an initial value of an empty string supplied. Very cool!
Is this true? I don't see how this bit handles the first element in a long list. Since reduce() is not given an initial value, doesn't it start with an index value of 1? From MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce): The index of the current element being processed in the array. Starts from index 0 if an initialValue is provided. Otherwise, it starts from index 1.