Skip to content

Instantly share code, notes, and snippets.

@layonthebeech
Created September 1, 2016 16:48
Show Gist options
  • Save layonthebeech/27e440956ebab16cc7df297ba24a314f to your computer and use it in GitHub Desktop.
Save layonthebeech/27e440956ebab16cc7df297ba24a314f to your computer and use it in GitHub Desktop.
IQ even odd test
function iqTest(numbers){
numbers = numbers.split(" ");
var even = numbers.filter(function(number) {
return number % 2 === 0;
});
var odd = numbers.filter(function(number) {
return number % 2 !== 0;
});
console.log(even, odd);
if(even.length > odd.length) return numbers.indexOf(odd[0])+1;
return numbers.indexOf(even[0])+1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment