JavaScript

May 25, 2023

How to find largest of three numbers in JavaScript

Find largest of three numbers in JavaScript program


let a = 10;
let b = 20;
let c = 5;
if (a > b && a > c) {
    console.log("a is Big ", a);
}

if (b > a && b > c) {
    console.log("b is Big ", b);
}

if (c > a && c > b) {
    console.log("c is Big ", c);
}

Output


b is Big  20

Steps Description

  1. Declare three variables a, b and c
  2. Initialize three variables with value of 10, 20 and 5 respectively a=5, b=10 and c=5
  3. if statement a greater b && operator a greater c check the condition a is big
  4. if statement b greater a && operator b greater c check the condition b is big
  5. if statement c greater a && operator c greater b check the condition c is big
  6. console.log inbuild function to display big variable number

by : Suhel Akhtar

Quick Summary:

How to find largest of three numbers with Logical AND ( && ) Operator in JavaScript with example