Build "Rock, Paper, Scissors (What am I doing wrong?)


#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";
}
};


#3

Try removing the /* in front of your code.
And what error are you getting?


#4

You have /* starting off your code at line 1. Then you have also placed */ after your console.log.

Do you know what these do to your code?

@dutchc0de you beat me by a minute, lol


#9

Haha, that happens to me a lot aswell.


#10

In this lesson the comments can stay on the top block of code. All that is needed is an exact representation of the first if conditional in the compare function.

The SCT error is the incomplete string.

"The result is a tie!"

#12

I fixed it so it is like this...

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";
}
};


But then there is an error that says "Oops, try again. Your compare function does not return 'The result is a tie!' when there is a tie."


#13

Like @mtf said, you're returning "The result is a tie" instead of "The result is a tie!". You're forgetting the exclamationmark.


#14

Oh, that makes so much more sense... Thanks :slight_smile:


#16

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