javascript - compare function syntax error -
i trying make rock paper scissors game code academy , told create function compare(). have written following code:
function compare(choice1,choice2){ if (choice1 == choice2){ console.log("the result tie!"); } else{ console.log("the computer wins"); } when run it, "the result tie!" appears twice error code saying "oops, try again! compare function not return 'the result tie!' when there tie." know there wrong syntax new don't know where. help?
you're not returning function, you're logging result. after either of console.log statements, send return
console.log("the result tie!"); return true; //or whatever
Comments
Post a Comment