1
我需要一個從100
到screenHeight - 400
的特定範圍內的隨機整數。具有特定範圍的隨機整數:值變得大於最大值
代碼如下,但爲什麼有值大於最大值?
for (var i = 0; i < 100; i++) {
const screenHeight = $(document).height(),
max = screenHeight - 400,
min = 100,
y = Math.floor(Math.random() * max) + min;
console.log(max, y, y > max);
}