This is a handy and useful function you can use for free to calculate the reduced percentage of any number. For example, if you want to know what is the total of 371 with a 80% off. [4757]

webune

Sun Jan 05, 2020

0 Comments

19 Visits

This functions works perfect if you have want to calculate the reduced percentage of a number.

For example, if you have an image and you want to reduce that image from its original size by 80 perfect.

If you have an image with the following dimensions: 371x400 we can calculate the image dimensions if we needed to reduce the image to 80%

The JavaScript Code:

function reduceByPercentage(originalSize,Percentage){

a = originalSize

a = a / 100;

b = a * Percentage;

b = Math.round(b);

return b;

}

Usage:

reduceByPercentage(371,80);

Demo:

Image Width Size

Reduce %

Results: