Plz help me with my code in : what if choice1 is rock?


#1

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 === "scisors")
    {
        return "rock wins";
    }
    else
    {
        return "paper wins";
    }
}

};


#2

@akanshyadash

This part

should be a comment.

Hint

A one-line comment is defined like this:

// I am a one-line comment!

A multiple line-comment is defined like this:

/* look, I'm
a multiple line
comment! */

#3

but y @miniapple8888???


#4

and yea...unfortunately im getting the same error :disappointed:


#5

Hi can ou post your new code ?


#6

You miss an "s" on "scissors"
if(choice2 === "scisors")

So the "scissors" is out and you don't cover all possible inputs for the game.


#7

hey got it fixed out...thanks a lot..by the way


#8

thanks a lot @dimitrispl