Cleanup baseRandom.

This commit is contained in:
John-David Dalton
2017-01-11 00:03:53 -08:00
parent 401c0f053c
commit 11052f4d87

View File

@@ -1,7 +1,3 @@
/* Built-in method references for those with the same name as other `lodash` methods. */
const nativeFloor = Math.floor;
const nativeRandom = Math.random;
/** /**
* The base implementation of `random` without support for returning * The base implementation of `random` without support for returning
* floating-point numbers. * floating-point numbers.
@@ -12,7 +8,7 @@ const nativeRandom = Math.random;
* @returns {number} Returns the random number. * @returns {number} Returns the random number.
*/ */
function baseRandom(lower, upper) { function baseRandom(lower, upper) {
return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); return lower + Math.floor(Math.random() * (upper - lower + 1));
} }
export default baseRandom; export default baseRandom;