1.2.12 Math


If we want to change the random value range from 0 and 1 to something else, we can multiply. So in our blackjack game, if we want to generate a random number between 1 and 52, we can multiply by 52…


A random number multiplied by 52...

Image of a random number 28.07148593622678

Another random number multiplied by 52...

Image of a random number 41.822779651194125

There may be an issue, however. The random function returns decimal places. There are times when you simply want a whole number. Thankfully, the math object comes with a function to handle that.


A random number with no decimal place...

Image of a random number with no decimal place, 33

Another random number with no decimal place...

Image of a random number with no decimal place, 48