Rock, Paper, Scissors


#1


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


What am I doing wrong?


#2

What's stopping you from finding out yourself? Ask about that instead.
The first thing to do is to determine how it behaves differently from how you want it to behave.


#3

Your secondary ifs aren't included in the brackets for your else-ifs. Example:

Your code:

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

Working code:

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

Do you see the difference?


#4

Yeah found it.Thanks!


#5

A post was split to a new topic: What am I doing wrong?


#7

A post was merged into an existing topic: What am I doing wrong?


#8