Operators are JavaScript's way of performing actions on data. Just like you use +
to add numbers in math, JavaScript uses operators to calculate, compare, and manipulate values.
They're the building blocks for creating dynamic websites that respond to user input and make decisions.
Engagement Message
What's one calculation you might need to do on a shopping website?
The most basic are arithmetic operators. JavaScript uses familiar symbols: +
for addition, -
for subtraction, *
for multiplication, and /
for division.
5 + 3
equals 8
.
10 - 4
equals 6
.
Engagement Message
Which arithmetic operator would you use to split a bill between friends?
Operators work perfectly with variables! You can perform calculations using the values stored in your variables.
let price = 25;
let tax = 5;
let total = price + tax;
