Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flip coin cmd #151

Open
wants to merge 3 commits into
base: multi-device
Choose a base branch
from

Conversation

salman0ansari
Copy link

fix #142

@Nagrom33
Copy link

This only return "1"

@AliFARHAT1
Copy link

AliFARHAT1 commented Oct 27, 2022 via email

@salman0ansari
Copy link
Author

This only return "1"

fixed

@AlePaff
Copy link

AlePaff commented May 14, 2023

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Flip a coin feature
4 participants