How to find the Maximum of Three Numbers in JavaScript - Step by Step Examples
How to find the Maximum of Three Numbers in JavaScript ?
Answer
To find the maximum of three numbers in JavaScript, you can use the `Math.max` function.
✐ Examples
1 Find Maximum of Three Numbers
In this example,
- We assign three variables
a
,b
, andc
with the numbers to compare. - We use the `Math.max` function to compare
a
andb
, and then compare the result withc
to get the maximum.
JavaScript Program
let a = 5;
let b = 8;
let c = 3;
let max = Math.max(a, b, c);
console.log(`Maximum of three numbers is: ${max}`);
Output
Maximum of three numbers is: 8
Summary
In this tutorial, we learned How to find the Maximum of Three Numbers in JavaScript language with well detailed examples.