Double conditions or "between"


Hello guys,

I was pointed out multiple times that using a string like

(3 <= x <= 100)

will result in the wrong result and that I should use

(3 <= x && x <= 0.66)

instead. I couldn't really find an explanation for it so I thought I would create a new topic about it.
Answers will be appreciated :relaxed:
Here is my code which I think works fine:

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


So what sort of testing have you done on your code if you can say it works fine ?
One of the big mistakes programmers make is not testing their code.


Just because you're code does not produce an error message does not mean it is working. The exercise deals with a random number which makes it harder to test the result and maybe some "solutions" pass although they should not. I ran a few test with your conditions over here:
and the results are terrible: in 1/5 cases the expected output and the output by this conditions matched.
I tried an explanation over here:
But if you have any further questions feel free to ask, a lot of people stumble upon this. This problem could possibly show you that error messages are you're friends and not your enemies because they tell you that something is wrong whereas here something is wrong but no one tells you.

PS: I also changed the title. If you don't like it change it back or to something else but I guess this way the problem is easier to see.


@haxor789 since you're a moderator, you probably already know this, but you are aware that Codecademy Labs aren't being supported anymore and that is a better option by the same person, and is supported, right?