mercredi 17 juin 2015

How do I randomly generate numbers 1 through 3 then assign a name to them?

I'm working on an a rock, paper, scissors game in Javascript, I've tried googling other examples of similar rock, paper, scissors games and they all pop up the same code. (Using Math.random) The instructions for my game are a little bit more precise.

First off the instructions say "When the program begins, a random number in the range 1 through 3 is generated. If the number is 1, then the computer has chosen rock, if the number is 2, the computer chose paper, if the number is 3 the computer chose scissors."

My question is how do I make the program chose a random number 1-3 and then have it recognize those numbers as rock, paper, or scissors?




Aucun commentaire:

Enregistrer un commentaire