Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Find Max/Min Value in an Array in JavaScript</title> </head> <body> <script> var numbers = [1, 5, 2, -7, 13, 4]; var maxValue = Math.max.apply(null, numbers); document.write(maxValue + "<br>"); // Prints: 13 var minValue = Math.min.apply(null, numbers); document.write(minValue); // Prints: -7 </script> </body> </html>