1
0
Fork 0

Fix poll percentage showing NaN

This happens when votes are still 0, so 0 divide by 0
This commit is contained in:
Lim Chee Aun 2022-12-14 01:48:55 +08:00
parent 975f3dd33f
commit d4cdf2435f

View file

@ -287,7 +287,8 @@ function Poll({ poll }) {
{voted || expired ? (
options.map((option, i) => {
const { title, votesCount: optionVotesCount } = option;
const percentage = Math.round((optionVotesCount / votesCount) * 100);
const percentage =
Math.round((optionVotesCount / votesCount) * 100) || 0;
return (
<div
class="poll-option"