Arithmetic Operators
๐จโ๐ผ We need to perform calculations in our programs. JavaScript provides
arithmetic operators for basic math operations.
The arithmetic operators are:
+Addition-Subtraction*Multiplication/Division%Modulo (remainder after division)
- Create variables
aandbwith any two numbers - Calculate and log the sum (
a + b) - Calculate and log the difference (
a - b) - Calculate and log the product (
a * b) - Calculate and log the quotient (
a / b) - Calculate and log the remainder (
a % b)
๐ฐ Example:
console.log('Sum:', 10 + 5) // 15
console.log('Remainder:', 10 % 3) // 1 (10 รท 3 = 3 remainder 1)