diff --git a/docs/math.html b/docs/math.html index 711292550..1991adea0 100644 --- a/docs/math.html +++ b/docs/math.html @@ -232,7 +232,7 @@ own individual rating by supplying it as the third argument.
randomIntegerInRange(0, 5); // 2
Returns a random number in the specified range.
Use Math.random() to generate a random value, map it to the desired range using multiplication.
const randomNumberInRange = (min, max) => Math.random() * (max - min) + min;
randomNumberInRange(2, 10); // 6.0211363285087005 -
Rounds a number to a specified amount of digits.
Use Math.round() and template literals to round the number to the specified number of digits. Omit the second argument, decimals to round to an integer.
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); +
Rounds a number to a specified amount of digits.
Use Math.round() and template literals to round the number to the specified number of digits. Omit the second argument, decimals to round to an integer.
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
round(1.005, 2); // 1.01
Hashes the input string into a whole number.
Use String.split('') and Array.reduce() to create a hash of the input string, utilizing bit shifting.
const sdbm = str => { let arr = str.split('');