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.
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.