Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript random numbers

var array = ["one", "two", "three", "four", "five"],
    result = array.slice(0, 3).map(function () { 
        return this.splice(Math.floor(Math.random() * this.length), 1)[0];
    }, array.slice());

console.log(result);
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #random #numbers
ADD COMMENT
Topic
Name
7+9 =