Rock Paper Scissors


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

Enjoying the Challenge but im lost, any help with be appreciated.


There are no functions after the else statement:


This sign is supposed to be >= instead of <=. Same goes for the else if statement.


As @ragezapper already mentioned else is the default case so you don't need a condition after it and it will lead to errors or at least unintended behaviour if it has one.
@ragezapper what's wrong about the <=?

another problem is this condition:

 else if (computerChoice>=0.34&&<=0.66){

the idea is good but the computer is not smart enough to see the context so it read it as

condition1: computerChoice>=0.34
condition2: <=0.66

So as it doesn't know that condition2 should be with computerChoice as well you probably get an error here so just use the long version with writing computerChoice <=0.66


Hey thanks for the answers,
I was thinking that if i had else if (computerChoice<=0.66) that it would over rule the if statement and include all under 0.34 aswell so was stuck on how to get it between.

So another quick question if I wanted to have a condition say between 50 and 75 how would I write this?
Would >=50<=75 alone be correct?

Thanks again for the help.


Well ironically this would have been fine:

else if (computerChoice<=0.66)

the if deals with less than 0.34 or 0.33 (doesn't matter as long as it is roughly 1/3 per choice) so to even reach the else if the number needs to be bigger than this so it is sufficient to just ask for smaller than 0.66 there as you did.


No. <,>,<=,>=, ==, !=, ==,===,!== are all binary operators meaning that they work on 2 values one on the left and one on the right of it so >=50 would already throw an error because of the missing left value.

What you do in this case is to make 2 conditions variable >= 50 and variable <= 75 and then chain them with a boolean operator e.g. && (AND) or || (OR) so when both should be true for a true condition you would use

variable >= 50 && variable <= 75

and when only one needs to be true you can use

variable >= 50 || variable <= 75


Ah I see, Thanks a million, appreciate the help.