Answers for "sample in javascript"

0

sample in javascript

function sample(arr, req) {
        arr = arr.sort(()=>{ return 0.5 - Math.random() }) ;
        let i = 0,
            array = [];
        while (i < req) {
            array.push(arr[i])
                ++i
        }
        return array
    }

//example  
let arr = [1,2,3 ,4,5] ;
console.log( sample(arr , 2) )   // will return two  random items
Posted by: Guest on May-15-2021
-2

javascript example

var c = 23;
Console.WriteLine(c);
Posted by: Guest on May-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language