Arithmetic Operation In JavaScript

Arithmetic Operation In JavaScript

·

2 min read

This Blog will teach you all about Arithmetic Operations In JavaScript.

Add Two Numbers with JavaScript:

JavaScript uses the + symbol as an addition operator when placed between two numbers.

Example:

const myVar = 5 + 10;//Adds 5+10 =15
const sum = 10 + 10;//Adds 10+10 =20

Subtract One Number from Another with JavaScript:

JavaScript uses the - symbol for subtraction.

Example

const myVar = 12 - 6;//Subtract 12-6=6
const difference = 45 - 33;//Subtract 45-33=12

Multiply Two Numbers with JavaScript

JavaScript uses the * symbol for multiplication of two numbers.

Example

const myVar = 13 * 13;
//myVar would have the value 169.
const product = 8 * 10;//8*10=80

Divide One Number by Another with JavaScript

JavaScript uses the / symbol for division.

Example

const myVar = 16 / 2;//myVar now has the value 8.
const quotient = 66 / 33; //66 divided by 22 = 2

Finding a Remainder in JavaScript

The remainder operator % gives the remainder of the division of two numbers.

Example

5 % 2 = 1 ;
17 % 2 = 1;//(17 is Odd)
48 % 2 = 0;//(48 is Even)

To Summarize :

  • Add Two Numbers with JavaScript
  • Subtract One Number from Another with JavaScript
  • Multiply Two Numbers with JavaScript
  • Divide One Number by Another with JavaScript
  • Finding a Remainder in JavaScript

Credits: I learned this topics in FreeCodeCamp which I explained in minified version

Thanks for reading the blog. Do let me know what you think about it.

Did you find this article valuable?

Support Surya's Web Blogs by becoming a sponsor. Any amount is appreciated!