Untitled

 avatar
unknown
plain_text
a year ago
289 B
3
Indexable
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