P3.2: JS Control Flow & Loops
Control flow allows programs to make decisions and execute code repeatedly.
1. Conditionals (if/else)
Decisions are evaluated using Boolean logic:
const score = 85;
if (score >= 90) {
console.log("Grade A");
} else if (score >= 80) {
console.log("Grade B");
} else {
console.log("Try again!");
}

Douglas CrockfordView Profile 🔗
Real-World Developer Case Study RoleAuthor of JavaScript: The Good Parts
Salary₹95 Lakhs/yr equivalent
CompanyPayPal Fellow (ex)
Core Tech Stack
JavaScript SpecsJSON StandardLinting Tools
“Always use strict equality operators (=== and !==) instead of loose comparisons (==). Loose comparisons execute silent type conversions, leading to bugs.”
2. Iteration Loops (for & while)
Execute blocks multiple times:
for (let i = 0; i < 5; i++) {
console.log("Iteration: " + i);
}