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

Feedback for “Passing Arguments” #4346

Open
cykei opened this issue Feb 18, 2025 · 1 comment
Open

Feedback for “Passing Arguments” #4346

cykei opened this issue Feb 18, 2025 · 1 comment

Comments

@cykei
Copy link

cykei commented Feb 18, 2025

I think current example code makes ERROR.

const root = {
  rollDice({ numDice, numSides }) {
    const output = [];
    for (const i = 0; i < numDice; i++) {
      output.push(1 + Math.floor(Math.random() \* (numSides || 6)));
    }
    return output;
  },
};

How about changing it like this?
The part I changed is...

  • const -> let
  • \* -> *
const root = {
    rollDice({ numDice, numSides }) {
        const output = [];
        for (let i = 0; i < numDice; i++) {
            output.push(1 + Math.floor(Math.random() * (numSides || 6)));
        }
        return output;
    },
};

Thank you.

@benjie
Copy link
Member

benjie commented Feb 18, 2025

Good catch!

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

2 participants