Skip to content

Instantly share code, notes, and snippets.

@ae5259
Last active March 16, 2023 15:02
Show Gist options
  • Save ae5259/29623a6da2465aa50c373699644b5928 to your computer and use it in GitHub Desktop.
Save ae5259/29623a6da2465aa50c373699644b5928 to your computer and use it in GitHub Desktop.
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