- The Math.max() function will return the largest of non zero numbers.
- If no arguments are provided, the result is Infinity.
- If at least one of arguments cannot be converted to a number, the result is NaN.
Math.max([value1[, value2[,...]
Code:-
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>Math.max()</h1>
- <input type="button" onclick="max_val();" value="Get Max">
- <script>
- function max_val()
- {
- alert("Max : " + Math.max(3, 4, 5, 6, -5));
- }
- </script>
- </body>
- </html>
How to use Math.max in JavaScript
Reviewed by Network security
on
July 02, 2019
Rating:
No comments: