13. Conclusion console.log help



I can't get it to print the final results from the return function. I expected to be able to see the message return in the console.log or as a dialog box but see nothing. Whenever I try to add a console.log to return the compare results since they are not showing on their own it either breaks something in the code or causes other issues.

var userChoice = prompt("Do you choose rock, paper or scissors?");
console.log("User: " + userChoice);
var computerChoice = Math.random();
if(computerChoice < 0.34) {
computerChoice = "rock";
else if(computerChoice <= 0.67) {
    comuterChoice = "paper";
} else { 
    computerChoice = "scissors";
console.log("Computer: " + computerChoice);

var compare = function (userChoice, computerChoice){
        return "The result is a tie!";
else if(userChoice==="rock") {
        return "rock wins";
        } else {
            return "paper wins";}
else if(userChoice==="paper") {
    if (computerChoice==="rock") {
        return "paper wins";
} else 
    return "scissors wins";


At this stage in the exercise we are not expected to output any results. However, if you wish to see the results, the log out the compare function return value.

console.log(compare(userChoice, computerChoice));


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