Computer >> Computer tutorials >  >> Programming >> Javascript

How to compare two numbers in JavaScript?


To compare two numbers in JavaScript, use the == operator. You can try to run the following code to compare numbers −

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         var a = 10;
         var b = 20 ;
         if(a == b) {
            document.write("True");
         }else {
            document.write("False");
         }
      </script>
   </body>
</html>

Output

false