-1

I am trying to make a rock paper scissors game for code academy and I was told to create a function for compare(). I have written the following code:

function compare(choice1,choice2){
if (choice1 == choice2){
    console.log("The result is a tie!");
} else{
    console.log("the computer wins");
}

when I run it, "The result is a tie!" appears twice but I get an error code saying "Oops, try again! Your compare function does not return 'The result is a tie!' when there is a tie." I know there is something wrong with my syntax but I am very new so I don't know where. Any help?

4

1 回答 1

0

您不是从函数返回,而是在记录结果。在任何一个console.log陈述之后,发回一个return

console.log("The result is a tie!");
return true; //or whatever
于 2013-09-04T15:29:33.013 回答