I need help on this


#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!";
    }
    else if(choice1 === "rock")
    {
     if(choice2 === "scissors")
     return ("rock Wins")
    }
    else
    {
        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#


#2

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


#3

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

I need help on this bit


#4

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


#5

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.


#6

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


#7

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


#8

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

#9

Where is my problem in this code?

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

:confused:


#10

Thank you , at least someone understands me


#11

Whats the problem ?or the error message coming up ?


#12

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 .


#13

it says there is a syntax error


#14

the console says SyntaxError: Unexpected token <


#15

never mind. I figured it out. :sweat_smile:


#16

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