Rock, Paper, Scissors

js

#1

I code still doesn’t run my code wrong. Can anybody help?

var userChoice = prompt("Are you ready to play rock, paper, scissors?(answer in lowercase)")
if (userChoice === "yes") {
    prompt("Do you choose rock, paper, or scissors")
} else if (userChoice === "no") {
    console.log("You are boring. Run the code again and say yes.")
} else { 
    console.log("That is not a valid answer. Run the code again and say yes")
}

var computerChoice = Math.random();
if (computerChoice <0.34){
    computerChoice = "rock";
}else if(computerChoice <=0.67){
    computerChoice = "paper";
}
else{
    computerChoice = "scissors";
}

var compare = function(userChoice,computerChoice){
    if (userChoice ===computerChoice) {
    console.log("The result is a tie!") ;   
    }

if (userChoice==="rock") {
    if(computerChoice==="scissors") {
        console.log("You Win!");
    }
    else {
        console.log("You loose!");
    }
}

if (userChoice==="scissors" ) {
    if (computerChoice==="paper") {
        console.log("You win!") ;
    }
    else {
        console.log("You loose!");
    }
}

if (userChoice==="paper") {
    if(computerChoice==="rock") {
        console.log("You win!");
    }else{
        console.log("You loose!");
    }

};
}
compare(userChoice,computerChoice);

#2

As much as it may (or may not) run, the code is an embellishment upon the suggested code in the instructions.

var userChoice = prompt("Do you choose rock, paper, or scissors")

#3

I know I just want to make it more interesting. It still says that something is undefined though


#4

Have you already completed the unit, or still in the process? If you have completed the unit, then by all means, code away, but if not, follow the exact instructions and pass the unit, before taking liberties with the required code.


#5

I have already completed it. Sorry for not being specific


#6

Remember to store the user’s choice in a variable.