const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = Math.min(...arr)
console.log(min)
const array = [320, 52, 532, 920, 20];
let smallestNum = array[0];
for (let i = 1; i < array.length; i++) {
if (array[i] < smallestNum) {
smallestNum = array[i];
}
}
console.log(smallestNum);
Array.min = function( array ){
return Math.min.apply( Math, array );
};
const array = [32, 22, 53, 92, 20, 34, 23, 11, 17];
let smallestNum = array[0];
let secondSmallestNum = 0;
for (let i = 1; i < array.length; i++) {
if (array[i] < smallestNum) {
secondSmallestNum = smallestNum;
smallestNum = array[i];
} else if (array[i] !== smallestNum && array[i] < secondSmallestNum) {
secondSmallestNum = array[i];
}
}
console.log(smallestNum);
console.log(secondSmallestNum);