Day 4: Arithmetic, Comparison & Logical Operators
Daily Objective
Section titled “Daily Objective”Perform calculations, evaluate comparisons, and construct compound conditions.
1. Arithmetic & Assignment
Section titled “1. Arithmetic & Assignment”let balance = 100;balance += 50; // 150balance -= 20; // 130balance *= 2; // 260balance /= 4; // 65const remainder = 10 % 3; // 1 (modulo)2. Comparison: Strict (===) vs Loose (==)
Section titled “2. Comparison: Strict (===) vs Loose (==)”Always use strict equality (===) and strict inequality (!==)!
5 === '5'; // false (checks value AND type)5 == '5'; // true (loose equality coerces types, dangerous!)3. Logical Operators
Section titled “3. Logical Operators”&&(AND): True only if BOTH conditions are true.||(OR): True if AT LEAST ONE condition is true.!(NOT): Inverts the boolean value.
const hasLicense = true;const isAdult = true;const canDrive = hasLicense && isAdult; // trueDaily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Write 5 comparison expressions evaluating combinations of numbers and strings using both
==and===. - Construct a compound logical condition testing if a user is eligible for a discount (e.g., student OR age under 25).