Javascript Basics: Comparing Values

April 26 2009, 9:05pm

Doing Arithmetic:

Operator What
=== Equal
!== Inequality
> Greater
< Less Than
>= Greater than or equal to
Less than or equal to

    function init()
    {
     var strA = "JavaScript" === "JAVASCRIPT";
     var strB = "JavaScript" === "JavaScript";

 var flt =  7.5 === 7.5 ;

 var intA =  8 !== 8 ;

 var intB = 24 > 12 ;

 var intC = 24 < 12 ;

 var intD = 24 <= 24 ;


 var str = "Is JavaScript = JAVASCRIPT = " + strA + "<br>";
 str += "Is JavaScript = JavaScript = " + strB + "<br>";
 str += "Is 7.5 equal to 7.5 =  " + flt + "<br>";
 str += "Is 8 inequal to 8 = " + intA + "<br>";
 str += "Is 24 greater than 12 = " + intB + "<br>";
 str += "Is 24 less than 12 = " + intC + "<br>";
 str += "Is 24 less than or equal to 24 =" + intD + "<br>";



document.getElementById("panel").innerHTML = str;



}
window.onload=init;

This will create the following: