Math.max() and Math.min() JavaScript math function

We can use Math.max() JavaScript math function to get highest value from a set of numbers. Here is the syntax
 Math.max(x1,x2,x3,….xn)
Here are some sample codes.
<script language='JavaScript' type='text/JavaScript'>
<!--
document.write(Math.max(3,12,4,14,7,5)); // output is 14
document.write("<br>");
document.write(Math.max(-5,6,-22,2,-20)); // output is 6
document.write("<br>");
document.write(Math.max(-12,-23,-3)); // output is  -3
//-->
</script>

Math.min() JavaScript math function

Math.min() JavaScript math function we can use to get the minimum value from a set of numbers
 Math.min(x1,x2,x3,….xn)
We will try some examples.
<script language='JavaScript' type='text/JavaScript'>
<!--
document.write(Math.min(5,6,2,20,8,5)); // output is 2
document.write("<br>");
document.write(Math.min(5,6,-10,2,20,8,5,-6)); // output is -10
document.write("<br>");
document.write(Math.min(-8,-5,-2)); // output is -8
//-->
</script>

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer