Rock Paper Scissors #7 Illegal Return Statement


#1


Im having trouble with this, and this is the closest to the bottom of the code I've gotten

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


SyntaxError: Illegal return statement


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


#2

The second curly brace in this line is closing the function body, which excludes the lines that follow. Move one brace to the very bottom of your code.


#3

Ok so I moved the bracket to the bottom but I'm still getting "Illegal return statement"

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

#4

Still too many braces before else if. Remove one.


#6

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