Javascript Array Sum via for 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 in order and adds // each element's value to total1 for ( let i = 0; i < theArray.length; i++ ) total1 += theArray[ i ]; console.log( "Total using subscripts: " + total1 );