I need help on 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!";
    else if(choice1 === "rock")
     if(choice2 === "scissors")
     return ("rock Wins")
        return ("paper wins")

That is my code I don't understand how to do this exercise https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661#


Mind explaining what it is you want to know/why you're stuck?


I tried this exercise more than 5 times I just don't get this p

I need help on this bit


You're not asking anything or describing a problem, there's nothing for me to respond to :confused:

You gotta start considering what it is you want to know, formulate questions, establish what the problem is


If you're wondering about how to approach the exercise, then my suggestion is to read over the instructions until you're sure you know how the code should behave.
Then start looking at the default code which you've screenshotted above, think about what behaviour needs to go where - they've already marked out which locations you need to be adding code. You can write what your code should do as comments in plain English, to be implemented as code once you've fully figured out what needs to happen.

I don't know whether this is the response you're looking for. I'm just guessing. There's a good chance what I just wrote is useless to you. Explaining what you're looking for makes it incredibly much easier to help out.

Figuring out what you need also makes it easier to get those things yourself, so that you're not just grabbing in the dark but instead you've got lots of information about what to look for.


I know what the problem is but it's hard to explain


I don't know what to fill that bit with :


Paper beats rock,
rock beats scissors,
scissors beats paper.

With this bit of code and the rules above you can solve this.

else if (choice1 === "paper"){
        if (choice2 === ){
            return ""
        } else {
            return ""


Where is my problem in this code?

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice ==< 0.33) {
} else if (computerChoice >== 0.67) {
} else {



Thank you , at least someone understands me


Whats the problem ?or the error message coming up ?


In the help or tip box it starts the statement with an if statement which was fishy . Now I understand the if goes under the else if .


it says there is a syntax error


the console says SyntaxError: Unexpected token <


never mind. I figured it out. :sweat_smile:


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