Lesson 6 Rock, Paper, Scissors. Illegal Return Statement?!?! HELP


#1


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


Illegal Return Statement


if(choice1 === choice2) {
    return "The result is a tie!"
    }
else if(choice1 === "rock") {

    if(choice2 === "scissors") {
            return "rock wins"
        } 
        else {
            return "paper wins"
        }

}
};


#3

Illegal Return Statement

return statement only make sense inside function.there is no function in your code

is it your full code?


#4

Yes that is the complete code


#5

did you read the instruction?

Inside the compare() function under the existing code, write an else if statement where the condition is choice1 === "rock".

so where is your compare function?


#6

var compare = function(choice1, choice2){
if (choice1 === choice2){
return "The result is a tie!";
}
};
if(choice1 === choice2) {
return "The result is a tie!";
}
else if(choice1 === "rock") {

if(choice2 === "scissors") {
        return "rock wins"
    } 
    else {
        return "paper wins"
    }

}


#7

you should close the function at the end

but now

var compare = function(choice1, choice2){
if (choice1 === choice2){
return "The result is a tie!";
}
};  //you shouldn't close the function here

#8

function choice(userChoice, computerChoice){
if(choice1 === choice2) {
return "The result is a tie!";
}
else if(choice1 === "rock") {

if(choice2 === "scissors") {
return "rock wins"
}
else {
return "paper wins"
}
}
}

var compare = function(choice1, choice2){
if(choice1 === choice2){
return "The result is tie!";
}
};

your placement seemed wrong. i just did this lesson and this was the answer.... by chrome standards


#9

Thank you, dude. I have been stuck here forever.


#10

i know i was to! lol happens homie :slight_smile:


#11

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