Build "Rock, Paper, Scissors": Both choices are the same!


#1

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/1?curriculum_id=506324b3a7dffd00020bf661


I've been stuck at this part of "Rock, Paper, Scissors" for a VERY VERY long time. I've been searching through codecademy discuss forums, and still haven't found a solution. And have tried everything I can think of to get the problem right. But no luck so far. (U.U) But that's why I'm making this topic. :slight_smile:

The problem it says I'm having is:

I've been trying to figure out how to get the 'compare' function to work, but I have no idea of what to do(since none of the discussions had the right solution to this issue).

Here's my code:

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

Thank you all! ^ ^


#2

I had the same struggle and could not believe my mistake:
Put an exclamation mark after" tie"


#3

It worked! ~Thank you ^ ^


#4

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