9 5 the accumulator pattern c2 b6

Solutions on MaxInterview for 9 5 the accumulator pattern c2 b6 by the best coders in the world

showing results for - "9 5 the accumulator pattern c2 b6"
Kris
29 Sep 2017
1let n = 6;
2let total = 0;
3
4for (let i = 1; i <= n; i++) {
5   total += i;
6}
7
8console.log(total);
9
10/*The variable total is initialized to 0. The loop executes once each for
11  the values of i from 1 to 6. Each time the loop body executes, the 
12next value of i is added to total.*/