Untitled

Anonymous
Plain Text
01/16/2024 1:18 PM
289 B
28
Indexable
Never
const calculatePercentage = (predecessorValue: number, recentValue: number): number => {
  const MAX_PERCENT = 100;
  if (!predecessorValue && !recentValue) return 0;

  if (!recentValue) return MAX_PERCENT;

  return ((recentValue - predecessorValue) / predecessorValue) * MAX_PERCENT;
};
Editor is loading...
Leave a Comment