GCGrowCarrer

Operators and Comparisons

Locked

Lesson 2 of 25 · Syntax · Easy

Finish these first:Variables and Primitive Types →Or pass the tests below to unlock it now.

1

The big idea

Operators let JavaScript do arithmetic and compare values. Write the math on the right side of =, and JavaScript saves the answer into the variable on the left: You can also compare two values using === (equal), < (less than), and (greater than), which produce true or false.

Think of it like this: Think of operators like the buttons on a calculator (`+`, `-`, `*`, `/`) that compute an answer before saving it in your variable.
Key words (tap to learn):
2

Read the lesson

Operators let JavaScript do arithmetic and compare values.

Write the math on the right side of =, and JavaScript saves the answer into the variable on the left:

let apples = 3 + 5;   // 8
let change = 10 - 4;  // 6
let area = 3 * 4;     // 12
let half = 10 / 2;    // 5

You can also compare two values using === (equal), < (less than), and > (greater than), which produce true or false.

3

Quick check

What does `let sum = 3 + 5;` store in `sum`?

4

Your challenge

2 sample tests, 1 hidden

Create a variable named total that adds 4 and 6 (type let total = 4 + 6;).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to python.operators (90% overlap). Arithmetic and boolean operators behave identically; watch === in JS and integer division in C++/Go/Rust/Java.

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Operators and Comparisons.

Mastery0%