JavaScript comparison with greater than operator

 JavaScript comparison with greater than operator

Doers JavaScript lesson, Section 2. #Doers

JavaScript offers greater than operator to compare values and return true or false depending on the comparison. 

Greater than operator is denoted by the > symbol. This is part of comparison operators in JavaScript. 

If the number on the left is greater than the number on the right, it returns true, otherwise it returns false.

Implicit type conversion is performed while using this operator.

<!DOCTYPE html>

<button onclick="greaterThan(5,10)">Check 5 > 10</button>
<button onclick="greaterThan(10,5)">Check 10 > 5</button>
<p id="result"></p>

    var x = document.getElementById("result");
function greaterThan(num1num2) {
    if(num1 > num2){
        x.innerHTML = true;
        x.innerHTML = false;


Post a Comment