• Home
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React.js
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
    • TypeScript
      • Introduction to TypeScript
      • TypeScript Developer
    • React
      • Introduction to React
      • React Developer
    • Python
      • Introduction to Python
      • Python Developer
    • C++
      • Introduction to C++
      • C++ Developer
    • C Language
      • Introduction to C
      • C Developer
    • Rust
      • Introduction to Rust
      • Rust Developer
    • Zig
      • Introduction to Zig
      • Zig Developer
    • Linux Shell
      • Introduction to the Linux Shell
      • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Reading Grounds

Quick Links

  • About Us
  • Pricing
  • Partnership
  • Brainstorm
  • Terms
  • Privacy
  • Refunds
  • Featured on DanielLaunches

Courses

  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer

Newsletter

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

© 2025 - 2026 STEMTrainingGrounds. All Rights Reserved.

Lesson 3

Lesson not found

Arithmetic Operators Typed Expressions

Lesson Progress: 0%

Lesson Progress: 0%
Arithmetic Operators Typed Expressions
Lesson Incomplete
Lesson not found
Code Example
let sum: number = 5 + 3;
console.log(sum);

let difference: number = 10 - 4;
console.log(difference);

let product: number = 6 * 2;
console.log(product);

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

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Typescript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here

Arithmetic operators let you do math with numbers in TypeScript. The four basic operators are + for addition, - for subtraction, * for multiplication, and / for division. Each variable is typed as number so TypeScript knows these are math values.

  • The + operator adds two numbers, so 5 + 3 produces 8.
  • The - operator takes one number away from another, so 10 - 4 produces 6.
  • The * operator multiplies numbers, so 6 * 2 produces 12.
  • The / operator divides numbers, so 20 / 5 produces 4.
  • Every result is stored in a number typed variable, which keeps your math safe and predictable.
Code Example
let remainder1: number = 10 % 3;
console.log(remainder1);

let remainder2: number = 7 % 2;
console.log(remainder2);

let remainder3: number = 12 % 4;
console.log(remainder3);

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Typescript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here

The modulo operator % gives you the remainder after dividing one number by another. It is not a percentage sign. It is a division leftover checker. You can use it to tell if a number is even, odd, or divides evenly into groups.

  • 10 % 3 equals 1 because 3 goes into 10 three times with 1 left over.
  • 7 % 2 equals 1 because 2 goes into 7 three times with 1 leftover slice.
  • 12 % 4 equals 0 because 4 divides into 12 perfectly with nothing left over.
  • If a number divided by 2 leaves 0, it is even. If it leaves 1, it is odd.
  • The % operator is very useful for cycling through items, checking divisibility, or keeping values within a range.
Code Example
let score: number = 10;
score += 5;
console.log(score);

score -= 3;
console.log(score);

score *= 2;
console.log(score);

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Typescript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here

Assignment operators combine an arithmetic operation with the assignment = operator. They let you update a variable by performing math on its current value and storing the result back into the same variable.

  • score += 5 is a short way to write score = score + 5. It adds 5 to the current value, turning 10 into 15.
  • score -= 3 takes 3 away from the current value, turning 15 into 12.
  • score *= 2 multiplies the current value by 2, turning 12 into 24.
  • TypeScript keeps the variable type as number, so the result of each operation stays a number.
  • These shorthand operators make your code cleaner and less repetitive when updating values.
Code Example
let count: number = 5;
count++;
console.log(count);

count--;
console.log(count);

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Typescript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here

The increment operator ++ adds exactly 1 to a number, and the decrement operator -- subtracts exactly 1. They are the shortest way to count up or down by one.

  • count++ is the same as count = count + 1 or count += 1.
  • Starting at 5, count++ moves the value to 6.
  • count-- is the same as count = count - 1 or count -= 1.
  • After decrement, the value goes from 6 back down to 5.
  • You will see ++ used a lot in loops and score counters to tick values up or down by one.
Code Example
let result: number = 5 + 3 * 2;
console.log(result);

let result2: number = (5 + 3) * 2;
console.log(result2);

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Typescript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here

TypeScript follows the standard order of operations, just like in math class. Multiplication and division happen before addition and subtraction. You can use parentheses () to force certain parts of the expression to be calculated first.

  • In 5 + 3 * 2, multiplication happens first: 3 * 2 = 6, then 5 + 6 = 11.
  • In (5 + 3) * 2, the parentheses force addition first: 5 + 3 = 8, then 8 * 2 = 16.
  • The order of operations is: parentheses, exponents, multiplication and division, addition and subtraction.
  • Both results are stored in typed number variables, so TypeScript keeps your math accurate.
  • Using parentheses makes your code easier to read and ensures the computer does exactly what you intend.
Code Example
let a: number = 15;
let b: number = 4;
let sum6: number = a + b;
let product6: number = a * b;
let remainder6: number = a % b;
console.log(sum6);
console.log(product6);
console.log(remainder6);

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Typescript Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here

You can combine multiple arithmetic operators in the same program to perform several calculations. Each result is stored in its own typed variable, and you can display them separately to see what each operation produced.

  • The variables a and b are both typed as number and hold the values 15 and 4.
  • a + b adds them together to make 19.
  • a * b multiplies them to make 60.
  • a % b finds the remainder of 15 divided by 4, which is 3.
  • TypeScript's number type guarantees that every result stays a number, so your calculations are always reliable.

Test Incomplete

What does the + operator do when used with two number values in TypeScript?

Question #

1/15

Score

0/0 - 0.0 %