Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function solution(input) {
input = input.toString().split('').map(x => +x)
let evenNumbers = input.filter((x) => x % 2 == 0)
let oddNumbers = input.filter((x) => x % 2 != 0)
let evenSum = evenNumbers.reduce((a, b) => a + b)
let oddSum = oddNumbers.reduce((a, b) => a + b)
console.log(`Odd sum = ${oddSum}, Even sum = ${evenSum}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.