compare variables JS

hello there :slight_smile:

   var a : float = System.Math.Round(1.23987, 2);
   var b : float = System.Math.Round(1.241, 2);
   
   if(a == b);
   {
      Debug.Log(a+" = "+b);
   }
   
   if(a != b);
   {
      Debug.Log(a+" != "+b);
   }

in log i can see 1.24 = 1.24 and 1.24 != 1.24 at the same time. why is that?

Because you have terminated the if statements with a Semi-colon which just leaves two blocks(the curly braces) and the debug statements. Remove the semi-colons on the end of the if statements.

    var a : float = System.Math.Round(1.23987, 2);
    var b : float = System.Math.Round(1.241, 2);
    
    if(a == b)
    {
       Debug.Log(a+" = "+b);
    }
    
    if(a != b)
    {
       Debug.Log(a+" != "+b);
    }