Loading lesson path
Arithmetic operators perform arithmetic on numbers (literals or variables).
+
*
** Exponentiation (
) /
% Modulus (Remainder) ++
--
A typical arithmetic operation operates on two numbers. The two numbers can be literals:
let x = 100 + 50;or variables:
let x = a + b;or expressions:
let x = (100 + 50) * a;The numbers (in an arithmetic operation) are called operands. The operation (to be performed between the two operands) is defined by an operator.
100 + 50
The addition operator ( + ) adds numbers:
let x = 5;
let y = 2;
let z = x + y;The subtraction operator (
) subtracts numbers.
let x = 5;
let y = 2;
let z = x - y;The multiplication operator ( * ) multiplies numbers.
let x = 5;
let y = 2;
let z = x * y;