Fundamentals10 / 12
Up next

for and for...of

const nums = [10, 20, 30];
// classic C-style loop with an index
for (let i = 0; i < nums.length; i++) {
  console.log(i, nums[i]);
}
// for...of walks the values directly
for (const n of nums) {
  console.log(n);
}
What you're solving

index loop vs value loop