const arr = [10, 5, 0, 15, 30];
const min = Math.min.apply(null, arr);
const index = arr.indexOf(min); // get the index of the min in the array
console.log(index); // 2
// Assuming the array is all integers,
// Math.min works as long as you use the spread operator(...).
let arrayOfIntegers = [9, 4, 5, 6, 3];
let min = Math.min(...arrayOfIntegers);
// => 3
(function () {
const arr = [23, 65, 3, 19, 42, 74, 56, -42, 8, 88];
// const arr = [];
function findMinValue(arr) {
if (arr.length) {
let min = Infinity;
for (let num of arr) {
min = num < min ? num : min;
}
return min;
}
return 0; // or anything what you need
}
console.log(findMinValue(arr)); // => -42
})();