Loops repeat a block while a counter changes.

Loops

loops.js
const limit = ;
let total = 0;

for (let number = 1; number <= limit; number++) {
  total += number;
}

console.log("limit=" + limit);
console.log("total=" + total);
const limit = ;
let total = 0;

for (let number = 1; number <= limit; number++) {
  total += number;
}

console.log("limit=" + limit);
console.log("total=" + total);
const limit = ;
let total = 0;

for (let number = 1; number <= limit; number++) {
  total += number;
}

console.log("limit=" + limit);
console.log("total=" + total);
for loop A `for` loop can initialize a counter, test a condition, and update the counter after each pass.