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: