Stuck in Buld rock paper scissors game


#1

Whats wrong with 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.34 && <=0.66) {
    console.log("paper");
    } else {
    console.log("Scissor");
    }

I am getting this error :confused: ;

Oops, try again. There was a problem with your syntax.


#2

the syntax error you are currently experiencing is here:

var computerChoice = Math.random() {
        console.log(computerChoice);
    }

math random is a function call, not a function declaration:

var computerChoice = Math.random();
// log the computerChoice to the console

don't use {}, no need. That should solve your current problem. There are more problems, please try to figure them out first yourself. Maybe take a look at thios topic, that should help you


#3

Also you want to make your comparison with a <= in this particular case so that it looks like this

if (computerChoice <= 0.33)

And here just one small edit, take the and operator out and you should be good!

else if (computerChoice >= .34 <= .66


#4

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