Added language data
This commit is contained in:
14
mock-api/dafa-web/scripts/utils/choose-random.util.js
Normal file
14
mock-api/dafa-web/scripts/utils/choose-random.util.js
Normal file
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user