var arr = [1,2,3,4,5,4,3,2,1] var resSum = 0; for(var i = 0; i < arr.length; i++){ resSum = resSum + arr[i] } console.log(resSum)