I am attempting to iterate through numbers from 0 to 100 and calculate the sum of even numbers and odd numbers in an array format, for example [2550, 2500]
.
let total = 0;
for(let num = 0; num <= 100; num++) {
total = total + num;
}
console.log(Array.from(String(total)));
However, this code outputs ['2', '5', '0', '0']
Could someone please guide me on how to display both sums as arrays?
Additionally, I need help with incorporating this code into another conditional statement so that I can obtain both the sum of odd numbers and even numbers. I'm having trouble deciding whether to use else if or if else....