We're a place where coders share, stay up-to-date and grow their careers.
This is the first I'm finding this, excited to play along! Here is yesterday's (edited to make the colors show up):
function stray(numbers) { let num1 = numbers[0], num2; let dupOf1 = false; for(let i=1; i<numbers.length; i++) { if(numbers[i] === num1) { if(num2) return num2; else dupOf1 = true; } else if(numbers[i] === num2) return num1; else num2 = numbers[i]; } return dupOf1 ? num2 : num1; }
This is the first I'm finding this, excited to play along! Here is yesterday's (edited to make the colors show up):