Math.max()

Math.max() can be used to find the highest value in a list of arguments:

   Math.max(0, 150, 30, 20, -8, -200);   // returns 150

HTML file: Displayed by browser:
<body>
<p>Math.max() returns the highest value:<p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
    document.getElementById("demo").innerHTML =
    Math.max(0, 150, 30, 20, -8, -200);
}
</script>
</body>

Math.max() returns the highest value:


BackTable of ContentsNext