BotsApp
BotsApp copied to clipboard
add flip coin cmd
fix #142
This only return "1"
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: @.***>
This only return "1"
fixed
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);