JavaScript addition, subtraction, multiplication, division | Simple Examples

Addition, subtraction, multiplication, and division are basic Arithmetic operations in JavaScript.

Addition Code: The addition operator (+) adds numbers:

Subtraction code: The subtraction operator (-) subtracts numbers.

Multiplication Code: The multiplication operator (*) multiplies numbers.

Division Code: The division operator (/) divides numbers.

JavaScript addition, subtraction, multiplication, division Examples

HTML complete example code for all basic athematic operations in JS (JavaScript). Users can choose or enter and select the option to calculate value dynamically.

In the example we used bootstrap and jQuery.

Output:

JavaScript addition, subtraction, multiplication, division example

The simple table shows the Arithmetic Operators

Arithmetic OperatorsOperationExample
+Addition10 + 2 = 12
Subtraction10 – 2 = 8
*Multiplication10 * 2 = 20
/Division10 / 2 = 5
%Modulus – It returns the remainder after the division10 % 2 = 0 (Here remainder is zero). If it is 10 % 3 then it will be 1.

Do comment if you have any doubts on this JavaScript topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.