I need an random integer in a specif range. The range is from 100 to screen height - 400.
So this is what I get, but why are there values greater then the max value?
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);
}
Aucun commentaire:
Enregistrer un commentaire