Skip to content

randomKey

Subhajit Sahu edited this page Dec 22, 2022 · 1 revision

Pick an arbitrary key.

Similar: randomKey, keys, has.


function randomKey(x, fr)
// x:  ientries
// fr: random number generator ([0, 1))
const ientries = require('extra-ientries');

var x = [["a", 1], ["b", 2], ["c", 3]];
ientries.randomKey(x);
// → "c"

ientries.randomKey(x);
// → "b"


References

Clone this wiki locally