March 24, 2017
var fruitList = ['Apple', 'Mango', 'Banana', 'Orange']
Find the length of the array and use Math.random() to pick a value. Math.floor() will help you to pick an integer close to the random number.
var randomFruit = fruitList[Math.floor(Math.random() * fruitList.length)]
You can use _.sample to pick a random sample from an array. You can also pass an extra parameter to tell the number of random value you need.
Will return one random value
Will return two random values
Similar to Underscore. But called as sampleSize