JavaScript Program to find the largest of three numbers

In this program, you will learn how to find the largest of three numbers in JavaScript.


if(condition){
   //statement
}else if(condition){
   //statement
}else{
   //statement
}

Javascript Program to find the largest of three numbers

Example: How to find the largest of three numbers in JavaScript

let x = prompt("Enter first number")
let y = prompt("Enter second number")
let z = prompt("Enter third number")

if(x > y && x > z){
  console.log("x is largest:"+ x)
}else if(y > z){
  console.log("y is largest:"+ y)
}else{
  console.log("z is largest:"+ z)
}

Output:

Enter first number> 30
Enter second number> 33
Enter third number> 10
y is largest:33