Last active
March 16, 2023 15:02
-
-
Save ae5259/29623a6da2465aa50c373699644b5928 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 sums(nums: number[]): {odds: number, evens: number} { | |
let odds: number = 0 | |
let evens: number = 0 | |
for(let num of nums) { | |
if(num%2==0) evens += num; | |
else odds += num; | |
} | |
return { odds, evens }; | |
} | |
const nums: number[] = [0,1,2,3,4,5,6,7,8,9,10]; | |
console.log(sums(nums)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment