In This Chapter
Generating random numbers and converting them to integers
Using the if-else structure
Managing multiple conditions
Using the switch structure
Handling unusual conditions
Random numbers are a big part of computing. They add uncertainty to games, but they're also used for serious applications like simulations, security, and logic. In this chapter, you generate random numbers to simulate dice and then explore various ways to modify the computer's behavior based on the value of the roll.
Math.random() function returns a random floating-point value between 0 and 1.
It's very easy to create a random floating-point number between ...