Created
May 4, 2021 21:50
-
-
Save borislavstoychev/b7d8e78b221b4c172f3afcec96e7856e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function foo(num) { | |
| 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}`; | |
| } | |
| console.log(foo(1000435)) | |
| console.log(foo(3495892137259234)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment