== Build "Rock, Paper, Scissors" ==
Computer Choice: Part 2
We have
Problem:
var computerChoice= Math.random();
if(0.33<computerChoice < 0)
{
computerChoice= "rock";
}
else if(0.64<computerChoice < 0.34)
{
computerChoice= "paper";
}else(0.67<computerChoice < 1)
{
computerChoice= "scissors";
}
Computer Choice: Part 2
We have
computerChoice
but it now equals a
random number between 0 and 1. We need to somehow translate this random
number into a random choice of rock, paper, or scissors. How do we do
this?!Problem:
- If
computerChoice
is between 0 and 0.33, makecomputerChoice
equal to"rock"
. - If
computerChoice
is between 0.34 and 0.66, makecomputerChoice
equal to"paper"
. - If
computerChoice
is between 0.67 and 1, makecomputerChoice
equal to"scissors"
.
var computerChoice= Math.random();
if(0.33<computerChoice < 0)
{
computerChoice= "rock";
}
else if(0.64<computerChoice < 0.34)
{
computerChoice= "paper";
}else(0.67<computerChoice < 1)
{
computerChoice= "scissors";
}
No comments:
Post a Comment