Problem with syntax


#1


I am stuck at Build Rock Paper Scissors 4 Computer Choice part 2


SyntaxError: Unexpected Token {


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


#2

Hi the else statement doesn't take any condition

if (condtion) {
    #Do something
}
else if (condtion) {
    #Do something
}
else {
    #Do something
}

and here you didn't close the else if condition

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

#3

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

This still isnt working and thank you.


#4

this line you didn't close the else if condition

} else if (computerChoice >= 0.34 && computerChoice <= 0.66

with )


#5

Thank you for your help!


#6

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