I cant seem to get it right!


#1


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

SyntaxError: missing ) after condition


if (choice1 === choice2) {
    return "The result is a tie!";
}
    
else if(choice1 === "rock")
{
    
    if (choice 2 === "scissors") {
        return "rock wins";
    }
    else{
        return "paper wins";
    }
}







Continuing the discussion from 7. What if choice1 is paper?:


#2

Please post your full code. :slight_smile:


#3

/*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 (choice 2 === "scissors") {
    return "rock wins";
}
else{
    return "paper wins";
}

}


#4

I just realized I put a space between choice and 2 in the 2nd if- statement. However, it is giving me the same syntax error even after fixing it!


#5

1.it should be choice2 not choice 2
remove space

if (choice 2 === "scissors") {
return "rock wins";

2.close the function
add } at the end

@simishr


#6

Got it! thank you so much @rcodeman :slight_smile: