Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
289 B
1
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;
};
Leave a Comment