I'm stuck please help


#1


why is it not working
 

var userChoice = prompt("do you choose rock paper or scissors?");
var computerChoice = Math.random();  
console.log(computerChoice)
if (0 0.33) {
   (= rock);
} else if (0.34 0.66) {
    = paper;
} else {
   = scissors;
}


#2

First, you're missing a semicolon. This will not stop your program from running, but it does build bad habits if you don't do it.

But your if statement is messed up. Ignoring the logic of your program, what are you writing in your if condition? What is (0 0.33)? You need to question a condition here, and what you are questioning is whether or not computerChoice is equivalent to 0, 0.33
Do not forget the comma in between your numbers to signal "through"!
The same goes for your else if statement, you need to question whether or not computer choice equals 0.34, 0.66. (Another simple way you can do this is by saying > 0.33, or > 0.66 for your if and else if statements respectively.)

Lastly, you need to do something inside of your if/else if/else statements. What equals rock, paper, or scissors depending on the number?


#3

then shouldn't this work?
var userChoice = prompt("do you choose rock paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if (0, 0.33) {
0, 0.33 = rock;
} else if (0.34, 0.66) {
0.34, 0.66 = paper;
} else {
0.67, 1 = scissors;
}


#4

Thank you for fixing your syntax errors!
Let's take this one step at a time.

Here, what you want to do is figure out if computerChoice equals 0, .33 right? How would you right that? What would you write in the parenthesis?

Same for

Hint: You want to do the same thing to both.


#5

it keeps on coming up with this
ReferenceError: Left side of assignment is not a reference.


#6

What that means involves the second part of your problem.

In each of these instances, how can 0.67, 1 for example equal scissors? What you want is to read the instructions...
If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors".
How can you do this for scissors paper and rock?


#7

do you mean like this?
var userChoice = prompt("do you choose rock paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if (0, 0.33) {
computerChoice = rock;
} else if (0.34, 0.66) {
computerChoice = paper;
} else {
computerChoice = scissors;
}


#8

Yes, very good! But read my second message talking about what you want inside of your parenthesis for if and else if.
It's the same variable we are talking about, you just want to check in your condition statement, (after the if, between the parenthesis), whether or not the variable is equal to those numbers. Do you remember the comparison operator?


#9

do you mean like this ? and no i don't think i remember the comparison operator. var userChoice = prompt("do you choose rock paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if (0, 0.33) {
computerChoice (0, 0.33) = rock;
} else if (0.34, 0.66) {
computerChoice (0.34,0.66) = paper;
} else {
computerChoice (0.67, 1) = scissors;
}


#10

No,

was closer. Leave everything alone and keep the code I showed above. The ONLY thing we are focused on now is

and

The problem is that you are not evaluating anything. Inside of an if statement, you would usually write something along the lines of

if (x === y) {
    # do something
}

Basically, you have everything right except for evaluating something. What do you need to evaluate? You simple need to use a comparison operator (the triple equal sign in my above code) and figure out what variable you are evaluating.
Do you know what variable you are evaluating? Its the only variable you have defined.


#11

do i put the comparison operator between the if/else if statements like this ?
if (0 === 0.33)
else if (0.34 === 0.66)


#12

No, you are evaluating a VARIABLE. What variable have you defined? I only see one, so you know you have to evaluate if(variable === 0, 0.33) and else if (variable === 0.34, 0.66).
Again, we know it can only be one variable, so which variable is it?


#13

the computerChoice variable


#14

Correct, awesome! Did you finish the code and get through the lesson? :slight_smile:


#15

not quite, it keeps on saying that it can't find the variable rock


#16

Can you post the entirety of your updated code?


#17

here it is
var userChoice = prompt("do you choose rock paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if (computerChoice === 0, 0.33) {
computerChoice = rock;
} else if (computerChoice === 0.34, 0.66) {
computerChoice = paper;
} else {
computerChoice = scissors;
}


#18

OHHH, your error message is telling you that rock isn't because it isn't, lol. But the reason it's telling you that is because the way you've written rock, paper, and scissors, they seem like variables.
Really, you were meaning to write them as strings. :slight_smile:


#19

hahahaha get now thanks for helping me:-)


#20

No problem! Sorry it took a while! I hope that you understand everything! :slight_smile: