Loops: for, while, do…while, for…of vs for…in
Loop basics: for, while, do…while, and when to use for…of vs for…in for arrays and objects.
Intro
Goal: Pick the right loop. Learn for, while, do…while, and when to use for…of vs for…in.
- Counted loops
- Condition loops
- Iterating values vs keys

for loop basics
for is ideal when you need the index and a stopping condition.
// Classic for: great for indexes
const nums = [2, 4, 6];
for (let i = 0; i < nums.length; i++) {
console.log("Index:", i, "Value:", nums[i]);
}

All lessons in this course
- if/else and switch — core patterns
- Loops: for, while, do…while, for…of vs for…in
- Early Returns and Guard Clauses