Javascript Array Sum via for in loop
let theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; let total1 = 0, total2 = 0; // iterates through the elements of the array using a for... in // statement to add each element's value to total2 for ( let element in theArray ) total2 += theArray[ element ];/* w ww . j av a 2 s . c om*/ console.log( "Total using for...in: " + total2 );