DEV Community

Cover image for LEVEL UP! Boost your JavaScript skills, LVL 3
DevCronin
DevCronin

Posted on • Edited on

LEVEL UP! Boost your JavaScript skills, LVL 3

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.

See the Previous Level Here

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


Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode


JavaScript

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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!

See the Next Level Here


Support and Buy me a Coffee

Top comments (0)