Last active
February 21, 2019 08:08
-
-
Save blended-ideas/810c6bad7ca72240655308d4492ab662 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cassidoo Newsletter Challenge - 2/21/19 | |
removeForOdd = (arr) => { | |
const sum = arr.reduce((a, b) => a + b); | |
if (sum % 2 !== 0) { | |
return -1; | |
} | |
return arr.findIndex(x => x % 2 !== 0); | |
} | |
# Same thing in a line. Coz, why not? | |
removeForOdd = arr => arr.reduce((a, b) => a + b) % 2 !== 0 ? -1 : arr.findIndex(x => x % 2 !== 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment