Table of Contents
show
Example 11
Write a JavaScript to find greatest of two numbers
const prompt = require("prompt-sync")();
let n1 = prompt("Enter the first number");
let n2 = prompt("Enter second number");
n1 = parseInt(n1);
n2 = parseInt(n2);
if (n1 > n2) {
console.log(`${n1} is greater than ${n2}`);
} else {
console.log(`${n2} is greater than ${n1}`);
}
Output

Views: 58