Help with 7. What if choice1 is paper?



var compare = function(choice1, choice2){
if(choice1 === choice2) {
return "The result is a tie!";
else if(choice1 === "rock" && choice2 === "scissors") {
return "rock wins";
else {
return "paper wins";
if (choice1 === "paper"){
if (choice2 === "rock"){
return "paper wins"
return "scissors wins"
illegal return statement apparently


Hey @bitsolver36606! Just change the returns with console.log();


thanks for the assistance! it works now


Couple of problems that I see. First looking at the brackets

else if(choice1 === "rock" && choice2 === "scissors") { /// opens else if
return "rock wins";
} ///closes else if
else ( ///opens else.  Also program won't look further because it found an else after a closed else if
return "paper wins"; ///without a nested if for choice 2 the default return statement will be "paper wins" unless the current else if is true
} ///closes else
} /// closes function

also that section of code should look more like the following to avoid problems like those noted above

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

Your next section of code also poses a problem as you have an if statement following an else if statement. And it also follows an else statement which is not allowed. the rest of that section looks good though

else if (choice1 === "paper") { /// change this line to else if as shown.  opens else if
if (choice2 === "rock") { ///opens nested if
return "paper wins";
} ///closes nested if
else { /// opens nested else
return "scissors wins";
} /// closes nested else
} /// This line is missing but it will close your else if
}; /// this line is also missing and it will close your function

no idea why someone thought simply changing the returns to console log would make this code correct