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.
Hell yeah! That's what I'm talking about
how's it work?
Ah thank you! I see my mistake now =D
If the actual object field was called
name
you could use eitherobj['name']
orobj.name
. However,name
is a variable that represents some other value in this case.Can someone please explain why
obj[name]
works here, butobj.name
does not?I thought an object could use either syntax.
It seems that if the outer loop is over wishlist, then one doesn't need to check for uniqueness.
I notice that solution assumes the input will always contain one and only one of each of the numbers 0 through 9, except for the missing one.
Since I like to write code that can handle the unexpected, I set my JavaScript solution up to find the first non-negative integer not contained in the array, or at least that was my intention. I realized as I submitted it, that it will return the first missing or duplicated non-negative integer. So for [9, 1, 2, 3, 4, 7, 5, 6, 5, 0] it would return 5, while for [1, 0] it would return 2, and for [27, 0, 18, 19, 2, 3, 4, 5, 1, 15, -7, 16, 17, 6, 7, 12, 13, 14, 20, 21, 8, 9, 10, 11, 22, 24, 25, 26, 99, 27, 135] it would return 23.
Nevermind, it was me :)
Is it just me or this solution doesn't work anymore?
These days I've learned a lot about reduce method. Thanks for this clever solution !
This comment is hidden because it contains spoiler information about the solution
Agree, though it is still slower in Firefox and IE11.
I am sure it will be someday the fastest solution.
I just tested it in Chrome 40, and map is now slightly faster than using a for loop.
This comment is hidden because it contains spoiler information about the solution
Voted this one up for being more efficient than the indexOf solution.
Loading more items...