Question #264547

  1. Write a program to print the sum of odd elements in the array

Expert's answer

var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];


sum =0;


for(var i=0;i<numbers.length;i++){
if (numbers[i] % 2 == 1) {
   sum+=numbers[i];
  }  
}


console.log("Sum = "+sum);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS