What if choice1 is scissors?


#1



SyntaxError: Unexpected token else


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 wins";
}
else if(choice1 ==="scissors") {
    
    if(choice2 === "rock")
    return "rock wins";
    }
    else { 
    return "scissors wins";
}

}

compare(userChoice,computerChoice)


#2

You're missing some braces / brackets / whatever you want to call them.


#3

Ok thank you ...I went back but every open brackets I closed....still not seeing it?


#4

no opening bracket here, but you have a closing bracket soon after.

same here

and here

You also don't close a few, like this one, so the next code block will only be active if the parent block is active. If you still can't find them all, I can find them for you I guess. Best of luck


#5

I am still not seeing it...i followed the same formula on the previous two and it went through fine i added the scissors and it wont go through


#6

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

    if (choice2==="scissors") { //one here
        return "rock wins";

}
else {
return "paper wins";
} } // one here
else if(choice1 ==="paper") {

if(choice2 === "rock") { // one here
return "paper wins";

}
else{
return "scissors wins";
} } // one here
else if(choice1 ==="scissors") {

if(choice2 === "rock") { //one here
return "rock wins";
}
else { 
return "scissors wins";

}
}// one here
}

compare(userChoice,computerChoice)


#7

i just got it! I was using the brackets wrong....i spaced each one out and went through it line by line. Thank you for your help and patience. This has been the first one that really stopped me. I under stand the logic of everything ...I need to review the brackets again.


#8

If you ever need more help, don't fret in calling me.


#9

Just wanted to say it's nice to see people actually taking their time to help on a forum instead of going off on the OP for not seeing the obvious. I just started learning to code a couple of days ago and im going through the lessons here, hoping to meet some people and learn this stuff, so far its a little overwhelming!


#10

If it becomes too much, take it slow. You'll still learn it all. You can also always go back through the course.

And don't be afraid to reach out to others on the forums. It tends to be mostly mods that answer, but sometimes others do too. But the mods tend to be nice and helpful all the same.


#11

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