To find the maximum of two numbers in JavaScript, you can use the Math.max function.
In this example,
a
and b
and assign values to them.Math.max
function to find the maximum of a
and b
and store it in a variable named max
.console.log
.// Maximum of Two Numbers
let a = 10;
let b = 15;
let max = Math.max(a, b);
console.log(`Maximum of ${a} and ${b} is: ${max}`);
Maximum of 10 and 15 is: 15
In this tutorial, we learned How to find the Maximum of Two Numbers in JavaScript language with well detailed examples.