Greater-than Operator


Comparison Greater-than

comparison greater-than operator takes two operands, returns true if value in left side operand is greater than that of the right operand, or false otherwise

> symbol is used for comparison greater-than operator

a > 5  //returns true if a has a value > 5
a > b  //returns true if a has a value greater than b

Examples

1. check if value in a is greater than 5

var a = 8;
if (a > 5) {
    console.log('a is greater than 5');
} else {
    console.log('a is not greater than 5');
}

2. check if value in a is greater than that of in b

var a = 5;
var b = 7;
if (a > b) {
    console.log('a is greater than b');
} else {
    console.log('a is not greater than b');
}