JavaScript program to find largest number from given 2 numbers


Following program shows you how to find largest number from given 2 numbers.
In this program we get inputs from user and shows largest number from given two numbers using if condition

var input1 = parseInt(prompt("Enter first number:"));
var input2 = parseInt(prompt("Enter second number:"));
if (input1 == input2) {
    console.log(input1 + " is equal to " + input2);
} else if (input1 > input2) {
    console.log(input1 + " is larger than " + input2);
} else {
    console.log(input1 + " is lesser than " + input2);
}

Output:

Example1:

Enter two numbers:
30
30
30 is equal to 30

Example2:

Enter two numbers:
50
10
50 is larger than 10

Example3:

Enter two numbers:
40
100
40 is lesser than 100