Given an array,print the sum of the even and odd numbers in the array.Javascript Program

const number=[3,4,5,12];
let sum=0;
let sum1=0;
for(let i=0;i<number.length;i++)
{
    if(number[i]%2==0)
    {
      sum=sum+number[i];
      
    }
    else if(number[i]%2==1)
    {
      sum1=sum1+number[i];
    }
    
}
console.log('Even Sum='+sum);
console.log('Odd Sum='+sum1);

Check Also

How to debugg our flutter application

Debugging a Flutter application involves a variety of techniques and tools to identify and fix …

Leave a Reply

Your email address will not be published. Required fields are marked *