Code says it is right, but something wrong?


Was just wondering, this is the code I have laid out. It is actually approving the code, saying it is correct and allowing me to move on, but for some reason when it generates a number between 0 and .33, (i.e, .00194...) it displays paper in the console rather than rock, unlike the code says it should. Any reason this could be? Am I missing something?

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

var computerChoice = Math.random();


if (0 < computerChoice < .33) {
    computerChoice = "rock";
else if (.34 < computerChoice < .66) {
    computerChoice = "paper";
else {
    computerChoice = "scissors";


You need to console.log() the result at the end, after the else.


Your conditions are completely wrong. While sth like A < B < C works in math and is widely understood, the computer doesn't understand it the way you think or want it to understand. A condition in Javascript consists of 2 values/variables and a comparison operator.
computerChoice >0.5
0 < computerChoice
ComputerChoice = 0.75

You have 3 values and 2 comparison operators. Thats why the computer can't evaluate this comparison properly.

You need to make 2 comparisons and then combine them.

if (computerChoice >0 && computerChoice < 0.33)

Here we have 2 conditions that have to be true at the same time for it to be true as a whole. Therefore we have to use the logical AND, which is represented by "&&". Let's say computerChoice had the value 0.5, then only the first part of the condition is fulfilled, therefore the condition as a whole (computerChoice >0 && computerChoice < 0.33)
is not fulfilled.