JavaScript Program to find the largest of three characters

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


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

JavaScript Program to find the largest of three characters

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

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

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

Output:

Enter first character> a
Enter second character> t
Enter third character> b
second is largest:t