Can someone help me?


#1

i really need help on this, im stuck!!
var userChoice = prompt("Do you choose rock, paper or scissor?");

var computerChoice = Math.random();

if (computerChoice<=0.33) {
alert("Rock");
} else if ((computerChoice>=0.34) & (computerChoice<=0.66)) {
alert("Paper");
} else {
alert("Scissor");
}


#2

to evaluate to conditions you shoud use two amersands &&,


#3

You don't really need to write the ampersands actually. The following code works because anything below 0.33 is being disregarded already before it proceeds on to the else if code.

if (computerChoice <= 0.33) {
    computerChoice = "rock";    
} else if (computerChoice <=0.66) {
    computerChoice = "paper";
} else {
    computerChoice = "scissors";
}

#4

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