Stuck and frustrated :(


#1

It says unexpected token else, I just cannot seem to figure out where it's wrong. If you could help I would greatly appreciate it! :smile:

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

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

};

#2

else may only follow after an if-statement, so check each one to find which doesn't.

You could also run it through some other interpreter that gives more verbose error messages, particularly line numbers.. You don't have that many else's to check though.

You might also want to fix your indentation so that it matches your braces. You might have put an else in a place where your indentation suggests it's OK, but where the braces say otherwise.