BotsApp icon indicating copy to clipboard operation
BotsApp copied to clipboard

add flip coin cmd

Open salman0ansari opened this issue 1 year ago • 4 comments

fix #142

salman0ansari avatar Aug 03 '22 09:08 salman0ansari

This only return "1"

Nagrom33 avatar Oct 27 '22 07:10 Nagrom33

hello is this an update for the

On Thu, Oct 27, 2022, 10:26 AM Gurdt @.***> wrote:

This only return "1"

— Reply to this email directly, view it on GitHub https://github.com/BotsAppOfficial/BotsApp/pull/151#issuecomment-1293105894, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXPFUXCFW5ZKA4PANKSIMLDWFIVDNANCNFSM55OCIS3Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

AliFARHAT1 avatar Oct 27 '22 14:10 AliFARHAT1

This only return "1"

fixed

salman0ansari avatar Oct 27 '22 16:10 salman0ansari

You must change from 'round()' to 'floor()'. Otherwise, if a value like 0.84 is rounded with 'round()' to 2 decimal places (0.84 * length = 1.68 -> 2), an index that doesn't exist will be selected. Resulting in an error.

The corrected code would be

let outcomesIndex = Math.floor(Math.random() * outcomes.length);

AlePaff avatar May 14 '23 00:05 AlePaff