6 - what if choice1 is "rock" - what am I doing wrong?


#1



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


Error message says "Oops, try again. There was a problem with your syntax." I just can't work out where I'm wrong. It looks the same as in the hint box but I must be missing something! Please help save my sanity?


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


#2

Ah worked it out by myself after about an hour of looking at it. Had to be the minute after I finally posted for help didnt it :slight_smile:


#3

I was just going to type your function doesn't have a matching closing curly bracket. Good you solved it yourself :slight_smile: