In this blog series tutorial, I will be covering some of the basic JavaScript programming concepts.
This is geared toward beginners and anyone looking to refresh their knowledge.
Level 3 will cover:
- Finding Remainder
- Compound Assignment Augmented Addition
- Compound Assignment Augmented Subtraction
- Compound Assignment Augmented Multiplication
- Compound Assignment Augmented Division
Finding Remainder
When dividing numbers that do not divide as a whole number, the remainder operator (%) can be used to find how much remains after the division.
let remainder = 13 % 2;
console.log(remainder);
// 1
Compound Assignment Augmented Addition
The compounded assignment uses the (+=) operator to do the mathematical operation and then assignment in one step. The mathematical operation to the right of the equal sign is always performed first and follows the order of operations.
let spellDamage = 10;
spellDamage += 5;
console.log(spellDamage);
// 15
Compound Assignment Augmented Subtraction
Compounded assignments can also be used with augmented subtraction using the (-=) operator.
let hitPoints = 20;
hitPoints -= 5;
console.log(hitPoints);
// 15
Compound Assignment Augmented Multiplication
By using the (*=) operator we can use compounded assignment for augmented multiplication.
var criticalHit = 2;
criticalHit *= 10;
console.log(criticalHit);
// 20
Compound Assignment Augmented Division
By using the (/=) operator we can use compounded assignment for augmented division.
var moveSpeed = 30;
moveSpeed /= 2;
console.log(moveSpeed);
// 15
Thank you for reading my blog! This is the third of my series on JavaScript so if you would like to read more, please follow!
...