Build "Rock, Paper, Scissors" 6. What if choice1 is rock?


#1

/*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(choice1, choice2)

if(choice1 === choice2) {
return "The result is a tie!"
}
else if (choice1 ==== "rock") {

 if (choice2 === "scissors") {

     return "rock wins"
 }
 else {

     return "paper wins"
 }

}

It comes up stating a syntax error Expected '{'
I can't figure out where I am missing it have been looking at it for almost an hour!

Can someone please help, I'm on the exercise What if Choice1 is rock? On the build, rock, paper scissors lesson.

Please help,

John


Replace this line with your code.


#2

var compare = function(choice1, choice2)
{
if(choice1 === choice2) {
return "The result is a tie";
}

else if(choice1 ==== "rock") {

 if(choice2 === "scissors") {
     return "rock wins";
 }
 else {
     return "paper wins";
 }

}

I think I found where the { was supposed to go although I still get a syntax error??


#3

You're missing a closing bracket at the end


#4

var compare = function(choice1, choice2)
{
if(choice1 === choice2) {
return "The result is a tie";
}
else if(choice1 ==== "rock") {

 if(choice2 === "scissors") {
     return "rock wins";
 }
 else {
     return "paper wins";
 }

}

}

I've put a bracket at the end, but I'm still getting a syntax error(just not a specific one), I've tried looking at all the previous lessons, the example and other websites, I just can't see what I'm missing??


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.