GK SOLUTIONS
AI • IoT • Arduino • Projects & Tutorials
DEFEAT THE FEAR

🚦 Lesson 4: Control Flow (Decision Making)

⏱️ Estimated time: 25 minutes | Difficulty: Beginner

Conditional Logic

Control flow allows your program to execute different pieces of code depending on whether a condition is true or false.

Arithmetic Operators

let a = 10, b = 3;
console.log(a + b);      // 13 (addition)
console.log(a - b);      // 7 (subtraction)
console.log(a * b);      // 30 (multiplication)
console.log(a / b);      // 3.333... (division)
console.log(a % b);      // 1 (remainder)
console.log(a ** b);     // 1000 (exponentiation)

Comparison Operators

console.log(5 == 5);     // true
console.log(5 === "5");  // false (different types)
console.log(5 != 3);     // true
console.log(5 > 3);      // true
console.log(5 < 3);      // false
console.log(5 >= 5);     // true

Logical Operators

let isStudent = true;
let hasID = true;

console.log(isStudent && hasID);  // true (AND)
console.log(isStudent || false);  // true (OR)
console.log(!isStudent);          // false (NOT)

✅ Quick Quiz

❓ What is 10 % 3?

❓ Is 5 === "5" true?

❓ What does && mean?

← PreviousNext →