1/9
Looks like no tags are added yet.
What is Control Flow?
•By default, code runs top to bottom once
•Control flow lets a program make decisions (conditionals) and repeat work (loops).
•Two questions it answers:
1.“Should I run this?
2.“How many times?”
•Analogy: IF the oven is hot, bake it; REPEAR stirring five times

Booleans & Comparison Operators
•A Boolean is either true or false, the result of every condition
•Comparison Operators return a Boolean:
•let age = 20
•age >= 18; // true
•age === 20 // true (checks value AND type)
•“5” == 5 // true (avoid: converts types)
•“5” === 5 // false (strict: prefer this)
Rule of thumb: ALWAYS use === and !==

If / else statements
•Runs a block only when a condition is true.
•Only the first matching block runs; else is the catch-all.

Logical Operators
●Logical operators are symbols or words like AND, OR, and NOT, used to combine or change true/false statements.
●AND (Conjunction): Returns true only if all inputs are true. &&
●OR (Disjunction): Returns true if at least one input is true. ||
●NOT (Negation): Reverses the truth value of the input. !
●They test multiple conditions at the same time to give a final true or false answer.

Switch Statements
●A switch statement is a control flow mechanism used in programming to execute a specific block of code from multiple options based on the value of a single expression.
Expression
●The variable or value evaluated exactly once at the start.
Case
●A specific value compared against the expression. If it matches, its code block runs.
Break
●A keyword that exits the switch block. Omitting it causes "fall-through," executing subsequent cases automatically.
Default
●An optional catch-all block that runs if no case matches the expression.

Loops
A for loop repeats a block of code a specific number of times.
A while loop is a code tool that runs a block of commands repeatedly as long as a certain rule or condition stays true. a code tool that runs a block of commands repeatedly as long as a certain rule or condition stays true. It checks the rule first, runs the code if the rule is true, and stops when the rule becomes false.
