May 25, 2023
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
- Declare three variables
a, b
andc
- Initialize three variables with value of 10, 20 and 5 respectively
a=5, b=10
andc=5
- if statement
a
greaterb
&& operatora
greaterc
check the condition a is big - if statement
b
greatera
&& operatorb
greaterc
check the condition b is big - if statement
c
greatera
&& operatorc
greaterb
check the condition c is big 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