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?
Similar Posts
- Find the maximum value from an array using Javascript
- Find the index of Max value in an array using Javascript
- Convert object {key: value} to Array [[key, value]] Javascript
- Array.find() - get the very first element satisfy a condition Javascript
- Simplest Way to Find the Smallest Number in an Array using JavaScript
- Find the Third Smallest Number in an Array using Javascript
- Find the shortest string in array