4/6 Help me fix my code? "unexpected token else"


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

I'm not sure why this isn't working. I'd love to get some input, but I do not want anyone to fix my code for me, I just want someone to point out what I specifically did wrong (something I hope codeacademy adds in the future). Thanks in advance!

I had a lot of issues with this particular course, likely due to the fact that they are all made by various different authors so the quality is a bit unreliable. Not complaining, just saying that the author didn't explain certain things too well.


#2

you need to open and close your if, else if, and else statements individually.for example your first if statement

if (choice1 === choice2) { ///opens here

but doesn't close. and your else if doesn't open with a {

compare your syntax with the portion of your code that is currently a comment as the yntax there is spot on

Hope this helps