JavaScript Basics
Lesson Progress0%
Basic Operations
Topic Overview
Take your time to understand each concept. Practice with the examples below!
Now that you can store data, let's learn how to work with it! JavaScript can perform calculations and combine information in useful ways.
Math Operations (just like a calculator!):
- •+ Addition:5 + 3 equals 8
- •- Subtraction:10 - 4 equals 6
- •* Multiplication:3 * 4 equals 12
- •/ Division:20 / 5 equals 4
- •% Remainder (modulo):10 % 3 equals 1 (10 ÷ 3 = 3 with remainder 1)
Working with Text (Strings):
- •+ Joins strings together (concatenation)
Example: "Hello" + " " + "World" equals "Hello World"
Comparison Operations (asking questions):
- •=== Equals:5 === 5 is true
- •!== Not equals:5 !== 3 is true
- •> Greater than:10 > 5 is true
- •< Less than:3 < 7 is true
- •>= Greater than or equal:5 >= 5 is true
- •<= Less than or equal:4 <= 8 is true
These comparisons always give you a boolean (true/false) answer!
Ready to practice? Try the exercise below to reinforce your learning!
Try it yourself
Calculate the area of a rectangle with width 10 and height 5. Store the result in a variable called "area".
Loading...