P3.2: JS Control Flow & Loops
Control flow allows programs to make decisions and execute code repeatedly.
Control flow allows programs to make decisions and execute code repeatedly.
Lesson: p3-2-control-flow
Control flow allows programs to make decisions and execute code repeatedly.
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!");
}
for & while)Execute blocks multiple times:
for (let i = 0; i < 5; i++) {
console.log("Iteration: " + i);
}