mardi 28 mars 2023

Why do we use Math.floor() for creating random numbers vs. Math.round() or Math.ceil()

So I am confused why we use Math.floor() for creating random numbers versus Math.round() or Math.ceil().

For example:

var enemyNumber = Math.floor(Math.random() * 4);

Why don't we use var enemyNumber = Math.ceil(Math.random() * 4); or var enemyNumber = Math.ceil(Math.random() * 4);




Aucun commentaire:

Enregistrer un commentaire