7. What if choice1 is paper


#1

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

please look at this code and tell me whats wrong with it


7. What if choice1 is paper?
#2

This is not the complete code for the lesson I suggest you paste in all of your code so we can help you find the error


#3

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

Not too sure what's wrong with my code here.


#4

You are closing your else if statement before else you need to close it after else and you have an extra curly bracket at the end.. Go through it carefully

Have a look at the correct syntax:

else if (condition) {
  if (condition) {
    // do something 
  } 
  else {
    // do something else
  }
}

#5

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