calculate-percentages
calculate-percentages
is a small utility that helps to calculate discounts, percentage changes, partial values, extensions, etc.
Notes
- Based on php-percentages by Mattias Geniar
Installation
npm i calculate-percentages
Usage
CommonJS Require:
const percentage =
ES6 Import:
Difference Between
The difference between two numbers is what percent?
percentage // -50percentage // 20 is 50% less than 40
Absolute Difference Between
The absolute difference between two numbers is what percent?
percentage // 50percentage // 20 is 50% less than 40
Calculate
What percent is one number of another?
percentage // 6.25percentage // 5 is 6.25% of 80
Of
What is the given percentage of a number?
percentage // 9percentage // 12% of 75 is 9
Extension
A given percent extension from one number to another is what?
percentage // 190percentage // 190 is the 90% extension from 100 to 200
Options
The last argument of any method is an optional options
object.
Option | Default | Use |
---|---|---|
verbose |
false |
Returns the value in a plain English statement for context |
License
MIT