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.
Daaaaamn!! Nice work
mind blown. genius!
map returns whatever you return
I didn't know that map returns 0/1 instead false/true.
When you post your code, just mark the "Mark as having spoiler content" box. Also, if you forgot it later you can do it by hovering over and clicking the "spoiler" button.
Sorry, whrere should I put it? Thx!
Use spoiler flag, please.
absolutely love it :)
var nums is a converted numbers(string) argument to an array by applying .split(), then .map() method returns a new array of 0s ans 1s;
var sum is the sum of all elements in "nums" array.
var target is being assigned to 0, or 1, as we know that nums contain ony 0s and 1s, if the sum is greater than 1, it means that majority of numbers were odd, otherwise even.
return statement is a beauty, because we search for an index of element with value 0, or 1, which is unique in 'nums' array.
How about this ? [2, 2, 2, 2, 2, 2, 2, 1]
This comment is hidden because it contains spoiler information about the solution
nice usage of map reduce
+1 for the map/reduce
If a single number is greater than 9...
sorry, you are right
it looks so hard ,very clever
Loading more items...