Can you tell me what to add next


#1

i have to change the value of computerChoice based on the rules stated above, If computerChoice is between 0 and 0.33, make computerChoice equal to "rock".
If computerChoice is between 0.34 and 0.66, make computerChoice equal to "paper".
If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors".
AND MY CODE SO FAR IS=
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 {
alert("Scissor");
}


#2

Hi @lorrainesuba,

If you didn't understand my instructions in my first post, please don't feel shy to ask for clarification. Creating a new post is unnecessary and ill-advised. :grin:

But like i said previously your problem is this condition,


#3

yeah but i dont know what to fix


#4

Your else if syntax is incorrect f you want to evaluate two conditions then you should write,

else if ( (computerChoice>=0.34) && (computerChoice<=0.66) ) {


#5

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