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.
best intuitive solution so far
Awesome thanks!
for...in
loops over enumerable properties. That means if any method was added toArray.prototype
incorrectly or lazily (or on purpose) that was enumerable, it would show up in the loop (and is probably undesired).Just curious, what is the danger in using
for...in
with arrays?A lot of repeated code here.. remember the DRY principle.
w
isn't declared anywhere, so you're creating a global variable. And usingfor...in
with arrays isn't usually a good idea (even if it worked in your solution). Either use a normalfor
loop or one of theArray.prototype
methods.Thanks.
For the performance: jsperf
It seems to be faster Math.max, on Chrome and Firefox.
You could use Math.max to calculate the length. I'm not sure which is faster tho.