I tryed to build noughts and crosses


var player1 = prompt("Chose your place:","EXAPMLE: C2").toLowerCase();
var komp = Math.random();
if((player1 === "a1") && (komp>=0,5))
var komp1 = "b2"
else if((player1 === "a1") && (komp<0,5))
var komp1 = "a2"


I dont know why komp1 always is b2, even if komp<0,5. Please help me understand.


I believe it is because you have commas for (komp>=0,5). You need periods so that the compiler can read it as a float 0.5. Right now, you are asking if komp >= 0 for the first if statement, which is always true since Math.random() gives you something 0 <= x < 1.


Thats it, thank you very much :slightly_smiling:


Yes the comma actually is an operator that lets you chain to statements A,B as one statement where the second statement B determines the value so here:


you compute komp >= 0 and never use it with a value of the statement of 5.