## Javascript compare with inequality operator

In Javascript we use the inequality operator to check if a particular condition passes or fails.

It is exactly opposite of the equality operator we've covered. If equality operator returns true, the inequality operator would return false.

Let's take a look at an example to understand this. Here, we are checking if the numbers are equal or not. In the first instance five is not equal to six. Thus the result is true. In the second insance, both the numbers are equal. Thus returns false.

<!DOCTYPE html>

<html>

<body>

<button onclick="inequality(5,6)">Check if 5 = 6</button>

<button onclick="inequality(5,5)">Check if 5 = 5</button>

<p id="result"></p>

<script>

var x = document.getElementById("result");

function inequality(num1, num2) {

if(num1 != num2){

x.innerHTML = true;

}

else{

x.innerHTML = false;

}

}

</script>

</body>

</html>

## 0 Comments