// will return the rounded percent of discount; // exceptions: for the values ending in 1, will display value - 1 // for the values ending in 9, will display value + 1 export const getRoundedMarkdownPercent = ( originalPrice: string, currentPrice: string ): number => { const calculatedPercent = Math.round( ((Number(originalPrice) - Number(currentPrice)) / Number(originalPrice)) * 100 ); if (calculatedPercent % 10 === 1) { return calculatedPercent - 1; } if (calculatedPercent % 10 === 9) { return calculatedPercent + 1; } return calculatedPercent; };