Please proofread the code 7/9


#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 (choice2 === "paper") {
 return "paper wins"; }
 
 }      
    
    else if (choice1 === "paper") {

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

}
}


#2

else usage cant contain a (condition)

if(condition){
}
else if (condition){
}
else { //there must be no condition.
}

#3

Hi 7even90,

You will get some "Unexpected token" errors for this because you have included additional conditions in the "else" part of the code. Check AlbionsRefuge post on if/else errors.

The below code has been cleaned up / changed in 3 areas:

1) else {
return "paper wins";
}

2) else {
return "scissors wins";
}

3) Inserted a semi-colon right at the end.

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

}

};

Hope that helps.


#4

Thank you jcdenton001 so much it was helpful!


#5

Thank you pointphoton so much it was helpful!