Created
October 18, 2019 04:28
-
-
Save vadimbogomazov/52358ec68dfa4341e3fb9d8cccad700b to your computer and use it in GitHub Desktop.
Get random integer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get random integer | |
* @param {Number} min – min integer number | |
* @param {Number} max – max integer number | |
* @return {Number} | |
*/ | |
export const randomInteger = (min, max) => { | |
const rand = min - 0.5 + Math.random() * (max - min + 1); | |
return Math.round(rand); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment