• Home
  • Python
    • Introduction to Python
    • Python Developer
    • Expert Python Developer
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
    • Expert JavaScript Developer
  • React.js
    • Introduction to React
    • React Developer
    • Expert React Developer
  • Linux
    • CyberSecurity - Introduction to Linux
    • CyberSecurity - Linux Administrator
    • CyberSecurity - Expert Linux Administrator
  • Active Directory
    • CyberSecurity - Introduction to Active Directory
    • CyberSecurity - Active Directory Administrator
    • CyberSecurity - Expert Active Directory Administrator
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • Python
      • Introduction to Python
      • Python Developer
      • Expert Python Developer
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
      • Expert JavaScript Developer
    • React
      • Introduction to React
      • React Developer
      • Expert React Developer
    • Linux
      • CyberSecurity - Introduction to Linux
      • CyberSecurity - Linux Administrator
      • CyberSecurity - Expert Linux Administrator
    • Active Directory
      • CyberSecurity - Introduction to Active Directory
      • CyberSecurity - Active Directory Administrator
      • CyberSecurity - Expert Active Directory Administrator
  • Interactive Training
  • Pricing
  • Brainstorm

Quick Links

  • About Us
  • Pricing
  • Brainstorm

Courses

  • Python
    • Introduction to Python
    • Python Developer
    • Expert Python Developer
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
    • Expert JavaScript Developer
  • React
    • Introduction to React
    • React Developer
    • Expert React Developer
    • Professional Master React Developer
  • Linux
    • CyberSecurity - Introduction to Linux
    • CyberSecurity - Linux Administrator
    • CyberSecurity - Expert Linux Administrator
  • Active Directory
    • CyberSecurity - Introduction to Active Directory
    • CyberSecurity - Active Directory Administrator
    • CyberSecurity - Expert Active Directory Administrator

Newsletter

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

© 2024 - 2026 STEMTrainingGrounds. All Rights Reserved.

Lesson 4 of 16

Lesson Progress: 0%

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:

Loading...

Editor Output:

Click "Run Code" to see the output here
  • A list is like a backpack where you can keep many different items together.
  • If you want to add something new to the end of your list, you use the append() helper.
  • Just tell Python which list you are using, then add the new item inside the parentheses.
  • For example, fruits.append("cherry") puts a cherry at the very end of your fruit list.

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:

Loading...

Editor Output:

Click "Run Code" to see the output here
  • Sometimes you have two different lists and you want to join them together into one big list.
  • Python has a helper called extend() that lets you pour one list into another.
  • It doesn't just add one item; it adds every single item from the second list to the end of the first one.
  • It's like taking two boxes of toys and dumping the smaller box into the bigger one to keep them all together.

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:

Loading...

Editor Output:

Click "Run Code" to see the output here
  • We can use a name like lives to store the number 3 so the computer remembers it.
  • When we use console.log, we are telling the computer to "read out loud" what is in the box.
  • You can change the number inside the box whenever you want, like when you find more coins!

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:

Loading...

Editor Output:

Click "Run Code" to see the output here
  • The double equals == is like a "close enough" check that looks at the meaning of the data.
  • It sees that the number 10 and the word "10" are twins, even though one is wearing "quote" clothes.
  • Sometimes it gets silly, like thinking 0 and an empty message "" are the same thing!
  • While this "friendly" check is helpful, most coders use a triple equals === for a much stricter "exact match" test.

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:

Loading...

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:

Loading...

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:

Loading...

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 meals = 4;
console.log(persons > 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:

Loading...

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:

Loading...

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:

Loading...

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 = 3;
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:

Loading...

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

const 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:

Loading...

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

const 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:

Loading...

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.
Lesson Progress: 0%
Lesson Incomplete
← Previous: Data Types (primitive vs reference)
Lesson 4 of 16
Next: Boolean Operators →