I continue to receive a syntax error and can't figure out why, please help.
alert ("CAN YOU BEAT VALERIE AT ROCK PAPER SCISSORS?");
var userChoise = prompt ("Rock, Paper, Scissors");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
}
else if (0.34 >= computerChoice < 0.67) {
computerChoice = "paper";
}
else (0.67 >= computerChoice <= 1) {
computerChoice = "scissors";
}
console.log("Valerie Dam picks" + " " + computerChoice);
Chrome Console throws the following syntax error:
Uncaught SyntaxError: Unexpected token { at Object.InjectedScript._evaluateOn (<anonymous>:895:140) at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34) at Object.InjectedScript.evaluate (<anonymous>:694:21)
0.34 >= computerChoice < 0.67
is not valid in JavaScript. Use something likecomputerChoice >= 0.34 && computerChoice < 0.67
instead.the last block of
else
[else (0.67 >= computerChoice <= 1)
...] should beelse if
.So your corrected code should be like this:
Working Fiddle