HELP! Computer Part 2 - Rock Paper Scissors


#1

Can someone please help me, and tell what is missing. Below is my code:

var userChoice = prompt("Do you choose rock, paper or scissor?")

var computerChoice = Math.random();
console.log(computerChoice);

if(computerChoice <= 0.33){
** computerCode="Rock";**
}
else if(computerCode <= 0.66){
** computerCode="Paper";**
}
else (computerChoice <=1){
** computerChoice="Scissors";**
}

This is the error I am getting: SyntaxError: Unexpected token {

Someone please help


#2

else (computerChoice <=1){

remember, "else" statements are all inclusive, meaning "no matter what else happens, I'll do this code"

All ELSE statements look like this:

else {
   //Your code here!
}

#3

I have revise my code but I am still getting an error message:
0.5367849802132696
ReferenceError: computerCode is not defined

Please help - my revise code is below:

var userChoice = prompt("Do you choose rock, paper or scissor?")

var computerChoice = Math.random();
console.log(computerChoice);

if (computerChoice<= 0.33){
computerCode="Rock";
}
else if (computerCode<= 0.66){
computerCode="Paper";
}
else{
computerChoice="Scissors";
}


#4

I try the code again, it seem to work now


#5


Help Me


#6

In your return statement you're missing the ) on the console.log. Also, you can just write return "The result is a tie!"; without the need to write console.log


#7

help
/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);*/
var compare = function(computerChoice, userChoice) {
if(computerChoice === userChoice) {
return "The result is a tie";
}
};
I can't figure out what is wrong with it.


#8

Hi here return "The result is a tie"; add a ! at the end of the string like that

return "The result is a tie!";

#9

thanks. I really appreciate it!