Skip to content

random.choice()

paige edited this page Nov 14, 2023 · 7 revisions

chooses a random entry in an object
type: Function


arguments:

  • ?object Any
    thing that it'll randomly choose from
    if not given it'll default to the binder

list: pair:
const { random } = require('stews');

let arr = ["a", "b", "c"];

console.log(random.choice(arr));
const { random } = require('stews');

let obj = { key1: "val1", key2: "val2" };

console.log(random.choice(obj));
"c"
[ "key1", "val1" ]