UNPKG

shopper

Version:
15 lines (12 loc) 301 B
export function calculatePercentOff({ currentValue, comparisonValue }: { currentValue: number comparisonValue: number }) { const difference = comparisonValue - currentValue const fraction = difference / comparisonValue const percentage = Math.round(fraction * 100) return percentage }