How to compare 3 Values in JavaScript-Code Examples

Radu TM

How to compare 3 Values in JavaScript

JavaScript by Radu TM June 22, 2022

let a = 1;
let b = 2;
let c = 3;

// compare the values of a, b, and c
if (a > b && a > c) {
  console.log("a is the greatest!");
} else if (b > a && b > c) {
  console.log("b is the greatest!");
} else {
  console.log("c is the greatest!");
}

0

22.572

Related JavaScript Queries

Latest JavaScript Queries

Explore code examples by categories