Step 7. cant figure it out, need tips


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

edit: not sure what happened to my indentation when pasting :confused:


#2

How to post code in this forum.


#3

thank you very much for your help!


#4

just to add to my post. i know that everything in the code is correct other then this which is the part of the exercise i am working on

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

its just this part that its not passing for me. Thanks for the help in advance


#5

That if statement needs to be closed in the proper place. Can you see where that should be?

edit -- oh, wait, I think you did, but the indenting makes it look like you did not. -- or not ... :slightly_smiling: check that part again.


#6

went back one lesson to check and re-wrote it to make sure and came up with this, which checks out.

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

#7

figured it out on my own!!!

i was putting my new peice of code right after the

return "paper wins";
        }

which should have been after like this

return "paper wins";
        }
    } //new code here