From 3cc6a3e674f1763891cc8231eeacf12494748ac1 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Thu, 14 Jul 2022 12:47:28 -0400 Subject: [PATCH] Try Math.round instead of Math.floor --- src/poll.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/poll.ts b/src/poll.ts index 626e512..590b7cb 100644 --- a/src/poll.ts +++ b/src/poll.ts @@ -49,14 +49,15 @@ export const renderPoll = async (card: TweetCard): Promise => { } } else { console.log('no choices found', values); + return ''; } console.log(choices); for (const [label, votes] of Object.entries(choices)) { // render bar - const bar = '█'.repeat(Math.floor((votes / totalVotes || 0) * barLength)); + const bar = '█'.repeat(Math.round((votes / totalVotes || 0) * barLength)); str += `${bar} -${label}  (${Math.floor((votes / totalVotes || 0) * 100)}%) +${label}  (${Math.round((votes / totalVotes || 0) * 100)}%) `; }