Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
@agarbiak

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 - seesource.

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;

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp