What if choice 1 is rock?


#1


What if choice 1 is rock exercise.


Syntax error message keeps popping up??


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


#2

var compare = function (choice1, choice2) {
    if (choice1 === choice2) // missing { to open if clause
    return "The result is a tie!";
}
else if(choice1 === "rock") {
    
    if (choice2 === "scissors") {
        return "rock wins";
    }
    else {
        return "paper wins";
    }
}
// missing } to close function

see coments in this code


#3

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