Files
2024-02-15 17:01:50 +00:00

9 lines
233 B
TypeScript

/**
* Format a fraction (0...1) into a percent, rounded to the nearest decimal place.
*
* toRoundedPercent(0.42555) === '42%'
*/
export default function toRoundedPercent(value: number) {
return `${Math.round(value * 100)}%`;
}