MCPcopy Create free account
hub / github.com/6dylan6/jdm / random

Method random

function/common.js:232–248  ·  view source on GitHub ↗
(arr, num)

Source from the content-addressed store, hash-verified

230 return random;
231 }
232 random(arr, num) {
233 var temp_array = new Array();
234 for (var index in arr) {
235 temp_array.push(arr[index]);
236 }
237 var return_array = new Array();
238 for (var i = 0; i < num; i++) {
239 if (temp_array.length > 0) {
240 var arrIndex = Math.floor(Math.random() * temp_array.length);
241 return_array[i] = temp_array[arrIndex];
242 temp_array.splice(arrIndex, 1);
243 } else {
244 break;
245 }
246 }
247 return return_array;
248 }
249 compact(lists, keys) {
250 let array = {};
251 for (let i of keys) {

Callers 1

randMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected