Search code snippets, questions, articles...

Find the maximum value from an array using Javascript

The code can be helpful to get the maximum value from an array using Javascript. We are using .reduce() method of array to find the maximum value from array.
const myarr = [10, 23, 32, 65, 7, 24];
const max_value = myarr.reduce((a, b) => a > b ? a : b);
console.log(max_value);

Example Demo

Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet