I tried the code 10000 times. Rock wins


#1

Can someone check this code, it is suppose to be right, I even make sure it is exactly equal to a solved solution. Any ideas where I might getting wrong?

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/2#


 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";
}
var compare = function(choice1,choice2){
    if(choice1===choice2){
        return "The result is a tie!";
    }
    if(choice1==="rock"){
        if(choice2==="scissors"){
            return "rock wins";
        }
        else{
            return "paper wins";
        }
    }


#2

Check the hint in the instructions. Look at the code they provide versus your code. Then, make sure to close your compare function.


#3

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