Answer to Question #264547 in HTML/JavaScript Web Application for swsq

Question #264547
  1. Write a program to print the sum of odd elements in the array
1
Expert's answer
2021-11-11T10:45:33-0500
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS