Skip to content

randomSuffix

Subhajit Sahu edited this page Dec 8, 2022 · 2 revisions

Pick an arbitrary suffix.

Similar: randomSuffix, suffixes, hasSuffix.


function randomSuffix(x, n, fr)
// x:  an array
// n:  number of values [-1 ⇒ any]
// fr: random number generator ([0, 1))
const xarray = require('extra-array');

var x = [1, 2, 3];
xarray.randomSuffix(x);
// → [ 2, 3 ]

xarray.randomSuffix(x, 1);
// → [ 3 ]

xarray.randomSuffix(x, -1);
// → [ 2, 3 ]
Clone this wiki locally