JavaScript Foundations

Basic operators

Use simple JavaScript operators to combine, compare, and change values in readable beginner examples.

Starter 4 practice exercises 1 homework item

What you will learn

  • Use simple JavaScript operators to combine, compare, and change values in readable beginner examples.
  • Recognize basic math and comparison operators without overload.
  • Understand that operators are symbols that do small jobs with values.

Lesson shape

14 minute lesson with 11 sections, 4 exercises, 8 checkpoint questions, and 1 homework submission.

Student mode saves sections, safe practice results, quiz progress, and completion status.

Lesson preview

Step-by-step structure before you start

Overview

What you will learn in this lesson

Operators can look intimidating at first because they are made of symbols instead of ordinary words. The important idea is much simpler than it looks.

Operators are symbols JavaScript uses to do small jobs with values.

Your lesson goals are simple:
- understand what an operator is in plain English
- recognize a few safe beginner operators
- tell the difference between math operators and comparison operators
- read tiny operator examples without rushing
- feel calmer when symbols appear in JavaScript

Symbols can still mean simple things

An operator is just a symbol that tells JavaScript what to do with the values around it.

Explain

What an operator is in plain English

An operator is a symbol that performs an action.

In beginner JavaScript, an operator might add numbers, subtract them, multiply them, divide them, or compare two values to see how they relate.

The operator sits between values and tells JavaScript what kind of work to do.

Look at the symbol between the values

The operator is the symbol in the middle. It tells JavaScript how to use the value on each side.

Explain

Math operators first

Some operators do math work:

+ adds numbers or combines text
- subtracts one number from another
* multiplies numbers
/ divides one number by another

These are useful because code often needs to count, calculate, or combine simple values in a readable way.

Math operators change amounts

If the values are numbers, math operators usually change the amount or result you get back.

Explain

Comparison operators next

Some operators compare values instead of changing them.

A comparison might check whether:
- two values match
- one number is bigger than another
- one number is smaller than another

Comparison operators matter because JavaScript often needs to answer simple yes-or-no questions before it can decide what to do next.

Comparisons lead to true or false

A comparison operator often gives back a boolean result such as true or false.

Practice

Tiny example 1: adding numbers

Here is a small example:

2 + 3

Line by line:
2 is one value.
+ is the operator.
3 is the other value.

The plus operator tells JavaScript to add the two number values together, so the result is 5.

The operator acts on both sides

The values on the left and right matter because the operator works with both of them together.

Practice

Tiny example 2: combining text

The plus operator can also combine strings:

"Hello, " + "Ava"

Line by line:
"Hello, " is one string value.
+ is still the operator.
"Ava" is the second string value.

In this kind of example, the plus operator combines text instead of adding numbers.

Plus does not always mean math

With strings, the plus operator combines text instead of adding amounts.

Practice

Tiny example 3: simple subtraction

Here is another example:

10 - 4

Line by line:
10 is the first number value.
- is the subtraction operator.
4 is the second number value.

The operator subtracts 4 from 10, so the result is 6.

Subtraction changes the amount

A math operator changes the number result based on the values on each side.

Practice

Tiny example 4: a simple comparison

Here is a comparison example:

5 > 3

Line by line:
5 is the value on the left.
> is the comparison operator.
3 is the value on the right.

JavaScript checks whether 5 is bigger than 3. It is, so the result is true.

Comparisons answer a question

A comparison operator checks the relationship between two values and often returns true or false.

Explain

What the operator is doing to the values on each side

A helpful reading habit is to ask:

- What value is on the left?
- What value is on the right?
- What job is the operator doing between them?

If the operator is + with numbers, it adds.
If the operator is + with strings, it combines text.
If the operator is > or < or a simple equality check, it compares the two values.

Read left, symbol, right

Many beginner expressions become easier when you read the left value, the operator symbol, and the right value in order.

Explain

Common beginner mistakes with operators

A few small mistakes happen often:

Mixing up adding numbers with combining text:
2 + 3 is different from "2" + "3".

Assuming all operators do the same kind of job:
Some do math. Some compare values.

Trying to learn too many symbols at once:
A few strong examples are better than memorizing a huge list.

Getting nervous when symbols appear in code:
The symbol is only one small instruction. You can slow down and ask what job it is doing.

Operator confusion is usually small

When an expression feels stressful, slow down and identify the operator's job before worrying about the whole line.

Wrap up

Short recap before lesson 5

Operators are symbols JavaScript uses to do work with values.
Some operators do math.
Some operators compare values.
The value on each side matters because the operator works with both of them.

You do not need advanced rules yet. If you can recognize a few basic operators and describe what they do, you are ready for conditionals next.

Understanding the job matters most

If you can name the operator and say what it is doing, that is a strong beginner win.

Keep moving

Finish this lesson, then move forward without losing your place.

Use the student player for saved sections, safe practice, quiz progress, and completion tracking.