Skip to content

Math.random code will only shuffle answer into first three containers #7

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

Closed
agarbiak opened this issue May 11, 2020 · 0 comments
Closed

Comments

@agarbiak
Copy link

agarbiak commented May 11, 2020

This was a really great tutorial series - easy to follow and quick to build!

I think I have found a small issue with the following code:

formattedQuestion.answer = Math.floor(Math.random() * 3) + 1;

Math.random() returns a value in the range [0,1), i.e. it will never return 1 - see source.

So it looks like the code will only return values of 1, 2 or 3. Never 4.

I think a simple fix is the following:
formattedQuestion.answer = Math.floor(Math.random() * 4) + 1;

JayantDwivedi added a commit to JayantDwivedi/Build-A-Quiz-App-With-HTML-CSS-and-JavaScript that referenced this issue May 26, 2020
@agarbiak agarbiak reopened this May 28, 2020
@agarbiak agarbiak closed this as completed Jun 1, 2020
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

No branches or pull requests

1 participant