Calculate the percentage of a number using Javascript

Percentage of a number

A percentage is a portion of a whole expressed as a number between 0 and 100 rather than as a fraction. For example, Students wants to calculate the percentage for marks. Similarly employee calculates percentage for the tax and salary hike. Lets see how to calculate the percentage of a number with example.

Percentage formula

P% * X

P – the percentage that we want to calculate. % – percent sign means divide by 100. X – a number

Example : 10 % of 350

Here we trying to calculate the 10 percentage of 350. First we need to multiply 10 with 350 and the result will be divided by 100. The output value is 35.

Another way to calculate percentage is (number 1/number2) * 100. Lets implement this calculation in the javascript

Calculate the percentage using javascript

We can design the percentage calculator using HTML and then we can execute this javascript to get the output value. We need to create text boxes to get the values and the calculate button is required to perform the percentage calculation.

Percentage calculator in HTML and Javascript

What is % of ?

Recommended Articles