parent
4acdbaebea
commit
005c66c60a
5 changed files with 36 additions and 11 deletions
@ -1,3 +1,9 @@ |
||||
export function getPercentage(portion: number, total: number) { |
||||
return portion > 0 ? ((portion / total) * 100).toFixed(2) : 0; |
||||
export function getPercentage(portion: number, total: number): string { |
||||
if (total <= 0 || portion <= 0) { |
||||
return '0'; |
||||
} else if (portion > total) { |
||||
return '100'; |
||||
} |
||||
|
||||
return ((portion / total) * 100).toFixed(2); |
||||
} |
||||
|
Loading…
Reference in new issue