aboutsummaryrefslogtreecommitdiff
path: root/src/components/PollCard
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/PollCard')
-rw-r--r--src/components/PollCard/PollCard.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index f222a63..f82ea44 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -72,10 +72,13 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => {
const handleLeft = () => vote('left');
const handleRight = () => vote('right');
- let leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
- let rightPercentage = 100 - leftPercentage;
+ let leftPercentage;
+ let rightPercentage;
- if(Number.isNaN(leftPercentage) && Number.isNaN(rightPercentage)){
+ if (left.votes || right.votes) {
+ leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
+ rightPercentage = 100 - leftPercentage;
+ } else {
leftPercentage = 0;
rightPercentage = 0;
}