Skip to content

Feedback for “Passing Arguments” #4346

Open
@cykei

Description

@cykei

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions