7/9 Rock Paper Scissors


#1

Hello Everyone, I been stuck in for a while. Pretty new to coding. Please help to see what I am doing wrong? It's a syntax error. Much appreciated!!

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

maybe here you will find the answer!

hope this helps!

Steven


#3

Hi Steven, I still didn't catch it :frowning:


#4

@byterunner28098 this is the thing I mean:

the if/else/else if syntax works like this:

if( something ) {
      do this
}else if(something else) {
      do that
}else{
      do this
}

instead of:

if( something ) {
      do this
}else if(something else) {
      if( do something ) {

       }
}else{
      do this
}

#5

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