javascript

Find the minimum value from an array javascript

We can easily get the minimum value from an array using javascript. we can use .reduce() function of array to make it easily.

const myarr = [10, 23, 65, 7, 24];
const min_val = myarr.reduce((a, b) => a < b ? a : b);
console.log(min_val);
Output
7

Here we have an array which has five integers values in it and we want to get the lowest value which this array contains. We are using .reduce() method of array for this purpose.

Example Demo

Was this helpful?