Is there a way to generate a random number in a specified range (e.g. from 1 to 6: 1, 2, 3, 4, 5, or 6) in JavaScript?
Example
Return a random number between 1 and 10:
Math.floor((Math.random() * 10) + 1);
The result could be: 3
3
Try yourself: here
--
or using lodash / undescore:
_.random(min, max)
Docs: - lodash - undescore