Squashed commit of the following: commit d3f52ff6876f6e246c7d3c188e56cc2370289341 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Aug 17 14:10:38 2021 +0200 Renamed all dafa instances to msfa
15 lines
297 B
JavaScript
15 lines
297 B
JavaScript
function chooseRandom(arr, num = 1) {
|
|
const res = [];
|
|
for (let i = 0; i < num; ) {
|
|
const random = Math.floor(Math.random() * arr.length);
|
|
if (res.indexOf(arr[random]) !== -1) {
|
|
continue;
|
|
}
|
|
res.push(arr[random]);
|
|
i++;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
export default chooseRandom;
|