Read on to discover new insights about these operations.
Most of us love Math, right? Well, maybe not everyone, but hey! Math is a fundamental part of our lives.
What are the basic arithmetic operators?
let SampleNumber = 8 + 8; console.log('Sum: ' + SampleNumber )
Subtraction helps you find the difference between two numbers. It subtracts one number from another.
let SampleNumber = 10 - 2; console.log('Difference: ' + SampleNumber );
Multiplication is used to calculate the product of two or more numbers. It multiplies two numbers together.
let SampleNumber = 8 * 8; console.log('Product: ' + SampleNumber );
Division allows you to divide one number by another.
let SampleNumber = 100 / 4; console.log('Quotient: ' + SampleNumber);
The modulus operator gives you the remainder when one number is divided by another. It returns the remainder of a division operation.
let SampleNumber = 64 % 5; console.log('Remainder: ' + SampleNumber);
The output is 4 because when 64 is divided by 5, the remainder is 4.
Increases a number by one. For example:
let i = 15; i++; console.log('Increment: ' + i)
Decreases a number by one. For example:
i = 15; i--; console.log('Decrement: ' + i);
Raises a number to the power of another number.
let power = 3 ** 3; console.log('Exponentiation: ' + power);
The output is 27 because 3 raised to the power of 3 equals 27.
Here’s an example:
// Declare and initialize variables let a = 8; let b = 8; // Addition let sum = a + b; console.log('Sum: ' + sum); // Outputs: Sum: 16 ✅ // Subtraction let difference = a - b; console.log('Difference: ' + difference); // Outputs: Difference: 0 ✅ // Multiplication let product = a * b; console.log('Product: ' + product); // Outputs: Product: 64 ✅ // Division let quotient = a / b; console.log('Quotient: ' + quotient); // Outputs: Quotient: 1 ✅ // Modulus (remainder of division) let remainder = a % b; console.log('Remainder: ' + remainder); // Outputs: Remainder: 0✅
These operations include addition, subtraction, multiplication, division, modulus (remainder of division), increment, and decrement. We also explored the exponentiation operation, which raises a number to the power of another number.
Thank you for reading Itsourcecoders 😊.