18 lines
337 B
JavaScript
Executable File
18 lines
337 B
JavaScript
Executable File
'use strict';
|
|
|
|
function shuffle(unshuffled, limit = 10) {
|
|
const shuffled = unshuffled;
|
|
|
|
for (let i = shuffled.length - 1; i > 0; i -= 1) {
|
|
const j = Math.floor(Math.random() * (i + 1));
|
|
const temp = shuffled[i];
|
|
|
|
shuffled[i] = shuffled[j];
|
|
shuffled[j] = temp;
|
|
}
|
|
|
|
return shuffled.slice(0, limit);
|
|
}
|
|
|
|
module.exports = shuffle;
|