IQ Test

JavaScript

function iqTest(numbers) {
  let evens = [], odds = [];
  numbers = numbers.split(' ').map(x => +x);
  numbers.forEach((num) => {
    num % 2 == 0 ? evens.push(num) : odds.push(num);
  });

  return numbers.indexOf(odds.length == 1 ? odds[0] : evens[0]) + 1;
}

Tags

  1. javascript (Private)
  2. 6-kyu (Private)
  3. codewars (Private)
  4. answer (Private)