== 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
computerChoiceis between 0 and 0.33, makecomputerChoiceequal to"rock". - If
computerChoiceis between 0.34 and 0.66, makecomputerChoiceequal to"paper". - If
computerChoiceis between 0.67 and 1, makecomputerChoiceequal 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