8. what if choice1 is scissors?


#1


why I can't see that message is who's win ?
I just can see "Computer: rock
[Function: compare]"
but the program say go to next step...
help me I want to see the message~



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("User: " + userChoice);
} 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 wins";
        }
    }
    else if (choice1 === "scissors"){
        if (choice2 === "rock"){
            return "rock wins";
        } else {
            return "scissors wins";
        }
    }
};

compare(userChoice, computerChoice);
console.log (compare);


#2

line 42 and 43 should be one line

on line 42 you call the function, you have two options: store the result of this function call in a variable, for example result, and log result to the console

Or use console.log() directly on line 42


#3

hey, check your line 9........erase line 9..
and follow the instructions given by @stetim94
hope this would help you........good luck


#4

if you're still stuck, please let me know:thumbsup:


#5

i wouldn't remove 9, i would move it somewhere where it would make more sense. But still, good spot :slight_smile:


#6

now It's work Thank you soso~~ much!
have a nice day!


#7

Thanks @ashmitkhare ! now it work! :smiley:


#8