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.
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.
Of course, you can always polyfill ;-)
It looks like .padEnd() was added to javascript with ECMAScript 2017. This kata uses node version 6.11.0 which was released before ECMAScript 2017, so that method doesn't exist in node 6.11.0. You'll have to solve this kata without .padEnd().
Here are some docs about .padEnd() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd