_.random
Returns a random element from an array
_.random(array, start?, end?)
Parameters:
array [array]:
the array with the elements
start?:
sets the minimum random index
end?:
sets the maximum random index
Example:
_.random([10,20,30,40,50])
// => Random value
_.random([10,20,30,40,50], 2)
// => 30, 40 or 50
_.random([10,20,30,40,50], 2, 3)
// => 30 or 40
Last updated