Finding the Maximum or Minimum in an Array of Numbers in Javascript


Use Math.max and Math.min along with spread operator to find extremes in an array.

Source Code

let numbers = [10, 5, 100, 2, 1000];
console.log(Math.max(...numbers)); // 1000
console.log(Math.min(...numbers)); // 2
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments