Skip to content

randomKey

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

Pick an arbitrary key.

Similar: randomKey, keys, has.


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

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

xlists.randomKey(x);
// → 'b'


References