Skip to content

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

Description

@agarbiak

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;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions