• Home
  • Python
    • Introduction to Python
    • Python Developer
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • React.js
    • Introduction to React
    • React Developer
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • Python
      • Introduction to Python
      • Python Developer
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
    • React
      • Introduction to React
      • React Developer
  • Interactive Training
  • Pricing
  • Brainstorm

Quick Links

  • About Us
  • Pricing
  • Partnership
  • Brainstorm
  • Terms
  • Privacy
  • Refunds

Courses

  • Python
    • Introduction to Python
    • Python Developer
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • React
    • Introduction to React
    • React Developer

Newsletter

Subscribe to our free monthly newsletter, for a quick update on Python, JavaScript, and React news

© 2025 - 2026 STEMTrainingGrounds. All Rights Reserved.

Introduction to JavaScript -

Lesson 3 of 15

Lesson Progress: 0%

Lesson Progress: 0%
Lesson Incomplete
← Previous: Data Types (primitive vs reference)
Lesson 3 of 15
Next: Boolean Operators →
Code Example
let sum = 5 + 3;
console.log(sum); // the answer should be 8

let result = 10 - 4;
console.log(result); // the answer should be 6

let product = 6 * 2;
console.log(product); // 12

let quotient = 20 / 5;
console.log(quotient); // 4

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • JavaScript operators are symbols like +, -, *, and / that help us do math.
  • The + operator adds numbers together, like 5 + 3 makes 8.
  • The - operator takes one number away from another, like 10 - 4 makes 6.
  • The * operator multiplies numbers, like 6 * 2 makes 12.
  • The / operator divides numbers, like 20 / 5 makes 4.
Code Example
let remainder = 10 % 3;
console.log(remainder); // the answer should be 1

// Sharing 7 slices of pizza with 2 people
let pizzaLeftover = 7 % 2;
console.log(pizzaLeftover); // the answer should be 1

// Putting 12 toys into 4 equal boxes
let toyLeftover = 12 % 4;
console.log(toyLeftover); // 0

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The % operator is called the modulo operator, and it gives you the leftover after dividing.
  • You can use % to check if a number is even or odd, because even numbers have no leftovers.
  • The example 10 % 3 gives 1, because 3 goes into 10 three times with 1 left over.
  • The example 7 % 2 gives 1, showing there is one slice left after sharing.
  • The example 12 % 4 gives 0, meaning everything divides evenly with no leftovers.
Code Example
let x = 7;
console.log(x); // the answer should be 7

// Keeping track of a player's lives
let lives = 3;
console.log(lives); // the answer should be 3

// Counting how many gold coins you found
let coins = 50;
console.log(coins); // the answer should be 50

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The = operator is used to give a value to a variable, like putting something into a box.
  • The example let x = 7; stores the number 7 so we can use it later.
  • The example let lives = 3; keeps track of how many lives a player has.
  • The example let coins = 50; stores how many coins were collected.
Code Example
console.log(5 == 5); // true

// Example 1: Comparing a number and a string
console.log(10 == 10); // true

console.log(5 == "5"); // true

// Example 1: Comparing a number and a string
console.log(10 == "10"); // true

// Example 2: Comparing the number zero and an empty-looking string
console.log(0 == ""); // true

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The == operator checks if two values are equal, even if they are different types.
  • The example 10 == 10 is true because both values are the same number.
  • The == operator is different from ===, because === also checks the type.
  • Sometimes == can be confusing, like 5 == "5" being true even though one is a number and one is text.
  • It can also give surprising results, like 0 == "" being true because it treats them as equal.
Code Example
const b = 5;
console.log(5 === b); // true

const c = 10;
console.log(10 === c); // true

console.log(5 === "5"); // false

// Example 1: Strict check between a number and a string
console.log(10 === "10"); // false

// Example 2: Strict check between a number and a boolean
console.log(1 === true); // false

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The triple equals === is a strict judge that requires things to be exactly the same.
  • It says false for 10 === "10" because a plain number is not the same as a word.
  • Even if the values look similar, this check makes sure the "type" of the box matches perfectly too.
  • Most professional coders prefer this strict way because it prevents the computer from making silly guesses.
Code Example
let count = 5;
count++;
console.log(count); // 6

// Giving a player a point in a video game
let score = 10;
score++;
console.log(score); // 11

// Counting how many levels you finished
let level = 1;
level++;
console.log(level); // 2

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The ++ symbol is a shortcut that tells the computer to "add one" to your number.
  • It is like a scoreboard that automatically clicks up by one every time you do something cool.
  • You can use it to keep track of how many items you have collected in a treasure hunt.
  • Instead of writing a long math problem, you just put ++ after the name to grow the number.
Code Example
let count = 5;
count--;
console.log(count); // 4 

// Losing a life in a game
let hearts = 3;
hearts--;
console.log(hearts); // 2

// Counting down the remaining cookies
let cookiesInJar = 10;
cookiesInJar--;
console.log(cookiesInJar); // 9

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The -- symbol is a quick shortcut that tells the computer to "subtract one" from your number.
  • It works exactly like a countdown, lowering the value by one every time the computer reads it.
  • You can use it to track how many tries a player has left before the game is over.
  • It is much faster than writing a long math equation when you just need to take away a single point.
Code Example
const guests = 5;
const seats = 4;
console.log(guests > seats);

// Checking if you have enough gold to buy a sword
const swordPrice = 10;
const myGold = 8;
console.log(myGold > swordPrice); 

// Checking if a car can fit under a bridge
const bridgeHeight = 12;
const carHeight = 9;
console.log(carHeight < bridgeHeight);

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The < and > symbols are like "Comparison Crocodiles" that check which number is bigger.
  • The computer gives you a true or false answer based on whether the rule you wrote is correct.
  • This is how games decide if you have enough points to level up or enough room to fit an item in your bag.
  • It helps the computer make simple decisions by comparing two different "boxes" of information.
Code Example
const guests = 5;
const meals = 4;
console.log(guests > meals);

// Checking if you have enough fuel for your rocket
const fuelNeeded = 100;
const fuelLevel = 150;
console.log(fuelLevel > fuelNeeded); 

// Checking if your backpack is too heavy
const maxWeight = 20;
const currentWeight = 25;
console.log(currentWeight > maxWeight);

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The > symbol is like a hungry crocodile that always wants to open its mouth toward the bigger number.
  • If the number on the left is bigger than the one on the right, the computer will give you a true answer.
  • This is a great tool for checking if you have "too much" of something, like a backpack that is getting too heavy.
  • It helps your program make smart choices, like deciding if a rocket has enough fuel to blast off into space!
Code Example
const leashes = 7;
const puppies = 3;
console.log(leashes >= puppies); 

// Checking if you have enough fuel for your rocket
const fuelNeeded = 100;
const fuelLevel = 150;
console.log(fuelLevel >= fuelNeeded); 

// Checking if your backpack is too heavy
const maxWeight = 20;
const currentWeight = 25;
console.log(currentWeight >= maxWeight);

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The >= symbol checks if the first number is bigger than OR exactly the same as the second one.
  • It is like a "Fair Share" rule that says true as long as you have enough for everyone, even if it's a perfect fit.
  • You can use this to see if a player has enough points to buy a new skin or unlock a secret level.
  • It combines the "Bigger Than" sign and the "Equals" sign into one powerful tool for making decisions.
Code Example
const cars = 2;
const parkingSpaces = 5;
console.log(cars <= parkingSpaces); 

// Can your group fit on a bench made for 3 people?
const people = 5;
const benchSeats = 3;
console.log(people <= benchSeats); // true (A perfect fit!)

// Is your suitcase light enough for the airplane?
const maxWeight = 50;
const myBagWeight = 42;
console.log(myBagWeight <= maxWeight); // true (It's under the limit!)

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The <= symbol checks if a number is smaller than or exactly equal to another number.
  • It is like a "Safety Limit" that says true as long as you don't go over the maximum allowed amount.
  • You can use this to see if a player is still young enough to play in a "Junior" game league.
  • It combines the "Less Than" sign and the "Equals" sign to make sure you stay within the right boundaries.
Code Example
let cars = 2;
cars += 1;
console.log(cars);
cars += 3;
console.log(cars) 

// Example 1: Gaining experience points (XP) in a game
let xp = 100;
xp += 50;
console.log(xp); // 150

// Example 2: Adding items to a shopping cart
let cartTotal = 2;
cartTotal += 1;
console.log(cartTotal); // 3
cartTotal += 5;
console.log(cartTotal); // 8

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The += symbol is a power-up that adds a new number to the current total and saves it.
  • It is like a piggy bank—you don't throw away what's inside; you just add more coins to the pile.
  • You can use it to increase a player's speed, health, or score as they move through your game.
  • It is a much cleaner way to write cars = cars + 1 by combining the math and the saving into one step.
Code Example
let cars = 25;
cars -= 1;
console.log(cars);
cars -= 3;
console.log(cars);

// Example 1: Spending gold coins in a shop
let gold = 100;
gold -= 20;
console.log(gold); // 80

// Example 2: Fuel leaking from a gas tank
let fuel = 50;
fuel -= 5;
console.log(fuel); // 45
fuel -= 10;
console.log(fuel); // 35

Instructions

▼ ← Click the triangle to hide or reveal instructions.

JavaScript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The -= symbol is a shortcut that subtracts a number from the total and saves the new result.
  • It is like a "Spending" button—it looks at how much you have and immediately takes some away.
  • You can use it to lower a character's health when they get hit or to reduce the number of arrows in a quiver.
  • Instead of writing out a long math sentence, it keeps your code tidy by doing the subtraction and saving in one go.

Test Incomplete

Which operator is used to add two numbers together?

Question #

1/15

Score

0/0 - 0.0 %