everyutil
Version:
A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.
16 lines (15 loc) • 524 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.percentDifference = void 0;
/**
* Calculates the percent difference between two numbers.
* For example, percentDifference(100, 80) returns -20.
* @author @dailker
* @param {number} a - The original value.
* @param {number} b - The new value.
* @returns {number} The percent difference from a to b.
*/
function percentDifference(a, b) {
return ((b - a) / a) * 100;
}
exports.percentDifference = percentDifference;