Rock, paper or scissors game


#1



Computer Choice: Part 2

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice <= 0.33) {
computerChoice = "rock";
} if else (computerChoice <= 0.66) {
computerChoice = "paper";
} else {
(computerChoice <= 1);
computerChoice = "scissors";
}
console.log("Computer:" + " " + computerChoice);

SyntaxError: Unexpected keyword 'else'. Expected '(' to start a 'if' condition.


Replace this line with your code.


#2

No parentheses inside an if/else statement should be placed. Remove it.


#3

still same error after removing parentheses in if/else statement.ar userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice <= 0.33) {
computerChoice = "rock";
} if else (computerChoice <= 0.66) {
computerChoice = "paper";
} else {
computerChoice <= 1;
computerChoice = "scissors";
}
console.log("Computer:" + " " + computerChoice);


#4

There's a typo, use else if


#5

thanks zolated, it worked beautifully after correcting the typo :wink: