[refactor] Moved 'getRandomInt' to its own TS file

This commit is contained in:
Steven Evans
2018-07-04 20:35:33 -04:00
parent 39c9488768
commit be9891d93b
9 changed files with 24 additions and 13 deletions

View File

@@ -0,0 +1,11 @@
/**
* Gets a random integer bounded by the values passed in.
* @param min The minimum value in the range.
* @param max The maximum value in the range.
*/
export function getRandomInt(min: number, max: number) {
const lower: number = Math.min(min, max);
const upper: number = Math.max(min, max);
return Math.floor(Math.random() * (upper - lower + 1)) + lower;
}