Console doesn't show the result


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/5?curriculum_id=506324b3a7dffd00020bf661


Hello, my code is considered working, but it isn't.
I can't display the result of battle on the console. The function seems ok, but while calling console.log(function), it doesn't even show anything on the console.

So apparently, the problem lies in the last line of the code.
Thanks.

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
}
console.log("Computer: " + computerChoice);
console.log("You: "+ userChoice);
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 if (choice2==='paper'){
            return"paper wins";
        }
    }else if(choice1==="paper"){
        if(choice2==='scissors'){
            return"scissors win";    
        }else if (choice2==='rock'){
            return"paper wins";
        }
    }else if(choice2==="scissors"){
        if(choice2==='rock'){
            return"rock wins";    
        }else if (choice2==='paper'){
            return"scissors win";
        }
    }else{
        return "wrong input";
    }
    console.log(compare(userChoice, computerChoice));
}


#2

a function call executes the function, you nested the function call inside the function. That doesn't work, place the function call outside the function


#3

Thank you very much :slight_smile:


#4