📜  9.5.累加器模式¶ - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:14.181000             🧑  作者: Mango

代码示例1
let n = 6;
let total = 0;

for (let i = 1; i <= n; i++) {
   total += i;
}

console.log(total);

/*The variable total is initialized to 0. The loop executes once each for
  the values of i from 1 to 6. Each time the loop body executes, the 
next value of i is added to total.*/