4. Computer Choice part 2


#1

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

im getting syntax error. I have looked it up and down 50 times, and it will not accept it. What is wrong with it.


#2
else (computerChoice >= .67 && computerChoice <= 1) {

else is the default case and therefor doesn't need a condition. So giving it one will only lead to confusion and errors. Now you've 2 options to fix this either get rid of the condition or make it an else if instead.


#3

Ah! Thanks haxor789. You are the man! unless you are a woman...then You are the woman!