Skip to content

Instantly share code, notes, and snippets.

@borislavstoychev
Created May 4, 2021 21:51
Show Gist options
  • Save borislavstoychev/745debc89999f280b2cd8deb2053eeb6 to your computer and use it in GitHub Desktop.
Save borislavstoychev/745debc89999f280b2cd8deb2053eeb6 to your computer and use it in GitHub Desktop.
demo
let evenSum = 0;
let oddSum = 0;
for (const n of String(num)) {
Number(n) % 2 == 0 ? evenSum += Number(n) : oddSum += Number(n)
}
return ` Odd sum = ${oddSum}, Even sum = ${evenSum}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment