JavaScript > Comparison Operators

Greater than or Equal to (>=) operator in JavaScript

How to check the value of the left operand is greater than or equal to the value of the right operand in JavaScript?


Greater than or Equal to (>=)

Greater than or Equal to operator is an Comparison Operator which is used to check the value of the left operand is either greater or equal to the value of the right operand.

If the value of the left operand is either greater or equal to the value of the right operand, the result gives 'true'.

The symbolic representation of Greater than or Equal to is >=

Left operand value is greater than right operand

<b>Assigning left operand value greater than the right operand value, the result gives</b>
<p id="myId"></p>

<script>
    var a = 10;
    var b = 6;
    var c = (a >= b);
    document.getElementById("myId").innerHTML = c;
</script>

In the above code snippet we assigned greater value to the left operand and lesser value to the right operand, we used greater than or equal to operator, so the result gives 'true'.

OUTPUT

Left Operand value is Equal to right operand

<b>Assigning left operand value equal to the right operand value, the result gives</b>
<p id="myId"></p>

<script>
    var a = 6;
    var b = 6;
    var c = (a >= b);
    document.getElementById("myId").innerHTML = c;
</script>

Greater than or Equal to with Equal values

In the above code snippet we assigned equal values to the left operand and right operand, so the result gives 'true'.

OUTPUT

 

Left operand value is less than right operand

<b>Assigning left operand value less than the right operand value, the result gives</b>
<p id="myId"></p>

<script>
    var a = 4;
    var b = 6;
    var c = (a >= b);
    document.getElementById("myId").innerHTML = c;
</script>

Greater than or Equal to with lesser value on left side

In the above code snippet we assigned lesser value to the left operand and greater value to the right operand, so the result gives 'false'.

OUTPUT

 Views: 16921 | Post Order: 173



Write for us






Hosting Recommendations