You need to sign in or sign up before continuing.×
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.
Esse final me pegou. Sempre dá um timeout. Não tenho ideia de como sair disso lol
0 is just a safer way to tell the accumulation to start at 0
No it doesn't assume initial value as 0, and it's optional:
initialValue Optional
A value to which previousValue is initialized the first time the callback is called. If initialValue is specified, that also causes currentValue to be initialized to the first value in the array. If initialValue is not specified, previousValue is initialized to the first value in the array, and currentValue is initialized to the second value in the array.
Source MDN
You're right. Reduce method requires a initial value, when not declared it assumes 0 but it can get nasty really quick.
I think the 0 serves as an initial value for the reduce method so you don't get an error if you get an empty array. I could be wrong though, lol.
Ops. I'm sorry :/
I'm coming from Javascript. How C # is different. I will have to study hard. JS is very abstract, but C # ... I will suffer a little, but I like it.
Please, use spoiler flag next time. Your posts are visible in the homepage otherwise. I'm not so sure it's really needed here, but...
This comment is hidden because it contains spoiler information about the solution
Sorry, I was sleepy :)
Open your browser console and type 0? true: false and then 0.1? true: false and keep changing the numbers. You will understand, it worked for me.
You forgot, I didn't even know! I'm learning a lot here
But, how does it work? Does this ', 0' function as an "or"?
WOW! I had done a kind of "IF" in my code that would return a [0] if the entry was empty. This is incredible, I have to study the reduce() method more.
Suggestions are welcome!
Loading more items...