Build "Rock, Paper, Scissors"


#1

1 If computerChoice is between 0 and 0.33, make computerChoice equal to "rock".
If computerChoice is between 0.34 and 0.66, make computerChoice equal to "paper".
If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors".
But there are three outcomes! Using if / else only lets us have two outcomes. What now?! We need to use if / else if / else. See the hint for the full syntax. You will laugh at how easy it is.

// I Have it right somewhat right :confused: need some help 
//here is what i have below 
var userChoice; 
var computerChoice;
userChoice= prompt("do you choose rock,paper or sissors?");


computerChoice= Math.random()
console.log(computerChoice)
if(0<computerChoice>0.33){
    computerChoice=("rock");
}
else if (0.34 <computerChoice> 0.66){
    computerChoice=("paper")
}
else if (0.67<computerChoice>1) {
    computerChoice=("scissors")
};

#2

The syntax for your if-statement evaluations are not correct.

The structure of the block would like the below, with the first if-statement looking something like:


if( computerChoice <= 0.33)
{
     insert code here
}
else if(some-code)
{
   insert more code
}
else(some-more-code)
{
   finish
}


#3

thanks a ton for the corrections


#4
0.34 <computerChoice> 0.66

This is really evil because it is not an error but still not behaving as expected. What happens is that it is executed in a row:

0.34 < computerChoice > 0.66
(0.34 < computerChoice) > 0.66
(true/false) > 0.66
and as true and false have numerical values of 1 and 0:
0/1 > 0.66

So if you go through the cases its almost the opposite of what you would expect it to be. So rather go with @dsenza's approach of not making it that complicated or make use of the boolean operators && (AND) and || (OR) to chain statement.