LESSON 6

Operators

Learning objective: Perform calculations and comparisons with operators.

Understand

Operators let you compute and compare values.

Arithmetic operators (+ - * / %) do math; comparison operators (=== !== > <) return booleans. Always prefer === over == because it compares without surprising type conversions.

Analogy: Operators are like the buttons on a calculator: each performs one action on your values.

See It in Action

Math and comparison:

let total = 5 * 3;      // 15
let isBig = total > 10;  // true
console.log(total, isBig);
How it works: The first line multiplies, the second compares and stores a boolean, and both results are logged.

Try It Yourself

  1. Compute a total with arithmetic operators.
  2. Compare two numbers with >.
  3. Compare two values with ===.

Quick Quiz

Why prefer === over ==?

Challenge

Write expressions that use at least three different operators.

Success condition: Your code correctly computes and compares values.