Else if choice 1 is rock?


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

Not sure why i get an error on else if (choice1 === "rock") {


#2
var compare = function (choice1, choice2) {
    
    if (choice1 === choice2) // missing {
    
    return "The result is a tie!";
   // missing } to close if
}; // this } closes the function, way to early
// the else if should be part of the function


    else if (choice1 === "rock") {
    
        if (choice2 === "scissors") // missing {
        
         return "rock wins";
    }
  else {
      return "paper wins";
  }
// missing } to close else if
// the function should be closed here

see the comments in code, many curly brackets are missing in your code, and some are missplaced


#3

I tried it, but it stills give me an error


#4

I can’t fix: i tried it, if you want me to help you give me something to work with:

code
error message
what you think that goes wrong


#5

Nevermind, got it to work! Thank you!


#6