Return not showing up


#1



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

No error messages, but the output doesn't show any of the return statements and only prints out what the computer has chosen.


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);

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!"
        }
        
    } else if (choice1 === "paper"){
        if (choice2 === "rock"){
            return "paper wins";
        } else { 
            return "scissors win";
        }
    } else if (choice1 === "scissors") {
        if (choice2 === "rock"){
            return "rock wins";
        }else { 
            return "scissors win";
        }
    }
  compare(userChoice, computerChoice);  
  
};


#2

You put the function call inside of the actual function... Remove it and it will run! :slight_smile:


#3

I just deleted your prompt. It worked fine.


#4

Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I just couldn't see, even when I was comparing to someone else's that worked. I was looking at everything except the last line location. Cheers :slight_smile:


#5

You're welcome!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:


#6

def greater_less_equal_5(answer):
if (15>5):
return 1
elif (4<5):
return -1
else:
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

From the about code I want to get the answer 1, -1 and 0, when I run the code I seen all my answer equal to 1's. So I need your help for the code. Thanks