Rock, paper, scissors


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661


The task keeps saying: "Oops, try again. There was a problem with your syntax."
I cannot figure out what I am doing wrong.

Help is very much appreciated, thanks.

This is what I've written in the task:
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";
           }

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

}

}



#2

Did you mean choice1?


#3

I have tried, but nothing seems to make a difference. Thanks for the reply.


#4

What did you try exactly? Make sure to refresh your browser after making corrections to your code before trying to save and submit.


#5

I have tried typing choice1 and choice2, but none of them seems to be working. I have also refreshed the page ;/


#6

Hmm, could you post all of your code? Maybe there's something else causing the error.


#7

I have already pasted in the entire code. But thanks for your help


#8

Have you tried using a different browser? What browser are you using?


#9

I am currently using Google Chrome. Should I try giving edge a try?

I have tried edge now. Still getting this error: "Oops, try again. There was a problem with your syntax."


#10

Weird. Can you paste your current code in?


#11

Sure thing. This is what I've done so far :slight_smile:
-
-
-
-

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";
           }

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

}

}


#12

Remove the ) after choice2 and see if this works


#13

You are a true genious my man. IT WORKED!

Thanks a lot for your effort, now can I finally continue :smiley:


#14

I'm glad it worked out :slight_smile:


#15

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