Syntax error / unsophisticated code / always prints "rock"


I have few problems with my code:
1. When I keep the curly braces, like they suggest it in the hints, it tells me there is a syntax error ( SyntaxError: Unexpected token { )
2. When I remove the curly braces, it kinda works, but always prints "rock" as computer's choice
3. Everybody here ask about "choice1" and I don't even know what it is. All the codes quoted here seem to be much different and more developed than mine. The desired outcome was: the user writes whatever and then the program randomly prints "rock" or "paper" or scissors", but in my case it's always rock.

var userChoice = prompt("answer")
var computerChoice = Math.random()
if (computerChoice < 0.33) {
} else if (0.34 < computerChoice < 0.67) {
} else (0.67 < computerChoice < 1) {


You've got a lot mixed-up -- including the logic. Please, kindly go through the instructions again.

I'll give a head start below.

var userChoice = prompt("answer");
var computerChoice = Math.random();
if(computerChoice <= 0.33) {
computerChoice = "rock" ;

Also, your else shouldn't have a condition/expression attached.


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