1var total = numbers.reduce(function(total, current) {
2 return total + current;
3}, 0);
4
5console.log(total);
1var array=[2,3,5,6,8,7,9]
2var sum =0
3for(var i=0; i<array.length; i++){
4if(array[i]===0){
5sum+=array[i]
6console.log(sum)
7}
8}
1///sum of odd numbers in an array javascript without loop
2var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
3
4var evenNumbers = numbers.filter(function(item) {
5 return (item % 2 == 0);
6});
7
8console.log(evenNumbers);