Someone help me


#1

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

var computerChoice = Math.random();
console.log(computerChoice)
if (computerChoice<=0.33) {
alert("Rock");
} else if ((computerChoice>=0.34) & (computerChoice<=0.66)) {
alert("Paper");
} else if ((computerChoice>=0.67) & (computerChoice<=1)) {
alert("Scissor");
}


#2

I'm not sure if this is important but you don't need to use alert.
Anyway if you do proceed with using alert to display the computer's choice, I would suggest adding a semicolon (;) after console.log(computerChoice).

The syntax for if / else if / else should be as follow (this was taken from the "Get a hint!" section):

if (condition1) {
    code code code;
} else if (condition2) {
    code code code;
} else {
    code code code;
}

Lastly you do not really need to use the && condition, since else if will only be run provided the computerChoice is more than 0.33, and else will only be run provided the computerChoice is more than 0.66.


#3

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