JavaScript(JS) JS find the largest among three numbers

To find the largest among three numbers in JavaScript/JS, we can use the Math.max() function. The Math.max() function returns the largest of zero or more numbers. We can pass the three numbers as arguments to the Math.max() function to find the largest among them. Here's an example:

re‮ef‬r to:theitroad.com
let num1 = 10;
let num2 = 20;
let num3 = 30;

let largest = Math.max(num1, num2, num3);

console.log(`The largest number is: ${largest}`); // Output: The largest number is: 30

In this example, we have three variables num1, num2, and num3 with values 10, 20, and 30 respectively. We have used the Math.max() function to find the largest among these three numbers and assigned it to the largest variable. Finally, we have displayed the result using the console.log() method.