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