Loops

for, while, for...of, and break.

for...of walks values. for with an index when you need the i.

Goal

Log each city and a running total.

const cities = ["Nairobi", "Mombasa", "Kisumu"];
for (const city of cities) {
  console.log(city);
}
let total = 0;
for (let i = 1; i <= 5; i++) {
  total += i;
  console.log(i, total);
}
const units = [12, 8, 5];
let i = 0;
while (i < units.length) {
  console.log(units[i]);
  i += 1;
}
for (const city of ["Nairobi", "Nakuru", "Eldoret"]) {
  if (city === "Nakuru") break;
  console.log(city);
}