mirror of
https://github.com/theoludwig/p61-project.git
synced 2024-07-17 07:00:12 +02:00
10 lines
177 B
TypeScript
10 lines
177 B
TypeScript
export const calculateRatio = (value: number, total: number): number => {
|
|
if (total <= 0) {
|
|
return 0
|
|
}
|
|
if (value >= total) {
|
|
return 1
|
|
}
|
|
return value / total
|
|
}
|