Rock, paper, scissors: if, else if, else: please help


Hi i just started learning and i have a problem, could you please tell me why "rock" remains the only option picked by the computer?

var userChoice = prompt("what do you want to pick? rock, paper or scissors")
console.log("you choose"+" "+userChoice)

var computerChoice=Math.random();

if (computerChoice < 0,34) 
    console.log("the computer choose rock!");
else if (computerChoice > 0,67)
    console.log("the computer choose scissors!");
else {
    console.log("the computer choose paper!");


Hi try to change how you wrote the number like that

0,33 to 0.33

0,66 to 0.67

With a dot.


@wizmarco is right. Unfortunately , is not a different decimal point but an operator that chains 2 statements where the latter one produces the output so in your case (a,b has a value of b):

a: computerChoice < 0
b: 34

And as you can read here:
all values not being 0 are treated as truthy, that's why you always pick rock.


thanks @wizmarco @haxor789