7. what if choice1 is paper


#1


I have no idea what the error is, can someone please help me?

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


Your code returned 'paper wins' instead of 'scissors wins' when the inputs are paper and scissors


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


#2

You make a return statement like this:

return "some input";

or if you are returning a variable like this:

return myName;

Maybe it will work then

Hope this helps

Steven


#3

If what @steven.copeland says doesn't fix it, please paste in your full code.


#4

I believe a word is missing before if on this line.


#5

@biff75 Actually when I was doing the course I did not put that in there. Thank you for posting that. I'll go and change that right away.


#6

@steven.copeland does your compare function work as intended? And if so, what is an else if for?


#7

This is the full code except for the part that the website change to a note.

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


#9

I mean it was like @cavemanpotter code here:

 if(choice1 === "paper"){

and I changed it to:

else  if(choice1 === "paper"){

#10

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