Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Find the Maximum and Minimum Value in an Array</title> </head> <body> <script> let numbers = [3, -7, 10, 8, 15, 2]; // Defining function to find maximum value function findMax(array){ return Math.max.apply(null, array); } // Defining function to find minimum value function findMin(array){ return Math.min.apply(null, array); } document.write(findMax(numbers) + "<br>"); // Outputs: 15 document.write(findMin(numbers)); // Outputs: -7 </script> </body> </html>