Rock Paper Scissor 6/9


#1


Replace this line with your code. 

This is what I did.
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){
    var choice1 = prompt("Do you choose rock, paper or scissors?");
    var choice2= computerChoice;
    if (choice1===choice2);{
    return "The result is a tie!";
} 

 else if(choice1 === "rock"); {
    
    if choice2 ==== "scissors") {
        return "rock wins";
}  
else{ 
    return "paper wins";
}

}


#2

if (choice1===choice2);{ // here

remove the ; after if statement

else if(choice1 === "rock"); { //same

next here

if choice2 ==== "scissors")

in this line try to find the errors

At last close the compare function by adding a } at the end

now call the function by giving arguments


#3

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