Stuck on if \ else for Rock, Paper, Scissors game - HELP!?


#1

I am getting the error "SyntaxError: Unexpected token <=". I am going out of my mind, as I have no idea why it is not working or how I can correct it.

Can someone please help!?


var userChoice =  prompt("Do you choose rock, paper or scissors?");

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

if (computerChoice <= 0.33) {
computerChoice == "rock";
}

else if (computerChoice >= 0.34 && <=0.66) {
computerChoice == "paper";
}

else {
computerChoice == "scissors";
}


#2

You should just be assigning in:

So, just one ( = ) should suffice.

Looking at the instruction for this,

The second part should be computerChoice <= 0.67. This is what is giving the error: "SyntaxError: Unexpected token <="


#3

Thanks for your help however I am still struggling "/

var userChoice = prompt( "Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);

if (computerChoice <= 0.33) {
computerChoice = "rock" }

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

else (computerChoice >= 0.67 && <=1.00) {
computerChoice = "scissors" }


#4

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