# How do I make the computer choice between 0 and 0.33 and so on

#1

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random()

if () {

computerChoice = "rock";

} else if () {

} else {

}

#2

Well Math.random gives you a random number between 0 and 1 (1 not included). So you just need to split this range into 3 parts on could also say divide it into 3 parts

#3

Hint:

You'll have to use either of these operators:
<, >, <=, >=, ===, !==

#4

I did

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

#5
``0.66>computerChoice>0.33``

This will not work as expected:

#6

//This is how I did it

var userChoice = prompt ("Choose rock, paper or scissors")
var computerChoice = Math.random()

``````if (computerChoice <= 0.33){
console.log("Rock");
}
else if (computerChoice > 0.33, computerChoice < 0.67)
{
console.log("Paper");
}
else
{
console.log("scissors");
}``````

#7
``computerChoice > 0.33, computerChoice < 0.67``

The comma operator chains 2 statements into 1 statement where the last of them creates the value so what you're actually saying is:

``computerChoice < 0.67``

which is correct but then you wounldn't need the computerChoice > 0.33 (which you in fact don't need)

#8

i assume you have solving the problem, but just in case you have'nt. try this

var userChoice = prompt("Do you choose Rock, paper or scissor?");
var computerChoice = Math.random();
console.log(userChoice);
if(computerChoice <= 0.33){
console.log("rock");
}
//javascript will execute your code from top to bottom, so don't get confused about the instruction beetween 0.34 to 0.66
else if(computerCoice <=0.66){
console.log("paper");
}
else{
console.log("scissors");
}

note,, try to understand the code before moving on to the next level..

#9

you can thank me latter

#10

Thank you for the correct answer Obin100, mine wouldn't work cause I didn't put parenthesis around if(computerChoice< .... I think there is a bug in the editor because your code works and sometimes I get error computerChoice not defined!