Skip to content

.choice() - option to actually return the choice? #3

@rhysstubbs

Description

@rhysstubbs

I am using the choice function in the following way:

  this.squash = hpjs.choice(methods.activation);

However, the choice function returns an object, the documentation makes out as if a random element in the array is returned. Am I misusing the function?

NB: I know that this could be achieved manually, but I am using the library so it makes sense to utilise functions that are available. The manual way could be:

this.squash = methods.activation[Object.keys(methods.activation)[Math.floor(Math.random() * Object.keys(methods.activation).length)]];

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