All files / server/src/features/assignment/utils toPercentage.ts

100% Statements 2/2
100% Branches 2/2
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6      50x 250x  
// Renders a share for a human-readable assignment summary. A zero total is a real outcome
// - nobody left to place, or no program items with lottery sign-ups - and reads better as
// 0% than as the NaN% a plain division would produce.
export const toPercentage = (part: number, total: number): string =>
  total === 0 ? "0%" : `${Math.round((part / total) * 100)}%`;