Build rock paper scissors game


#1


I am not sure why my answer is constant scissors instead of getting a random answer for the Math.random().

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


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


#2

else can't have a condition, since its everything else

having too many semi-colons:

( 0.67<computerChoice<1 ); // this one

can also be a problem. Js will understand the comparison you are doing, but recommend is to use the and (&&) operator, if you want to do multiply comparisons. If you think about it, you only need to check one condition. For else if, you don't need to check if the value is greater then .33, give your if condition catches this


#3

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