Skip to content

Instantly share code, notes, and snippets.

@vadimbogomazov
Created October 18, 2019 04:28
Show Gist options
  • Save vadimbogomazov/52358ec68dfa4341e3fb9d8cccad700b to your computer and use it in GitHub Desktop.
Save vadimbogomazov/52358ec68dfa4341e3fb9d8cccad700b to your computer and use it in GitHub Desktop.
Get random integer
/**
* 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