Skip to content

Feedback for “Passing Arguments” #4346

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
cykei opened this issue Feb 18, 2025 · 1 comment · Fixed by #4369
Closed

Feedback for “Passing Arguments” #4346

cykei opened this issue Feb 18, 2025 · 1 comment · Fixed by #4369

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

Successfully merging a pull request may close this issue.

2 participants