1const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
2const min = Math.min(...arr)
3console.log(min)
1//Not using Math.min:
2const min = function(numbers) {
3 let smallestNum = numbers[0];
4for(let i = 1; i < numbers.length; i++) {
5 if(numbers[i] < smallestNum) {
6 smallestNum = numbers[i];
7 }
8 }
9return smallestNum;
10};
1Array.min = function( array ){
2 return Math.min.apply( Math, array );
3};
4var minimum = Array.min(array);
1var arr = [5,1,9,5,7];
2var smallest = arr[0];
3
4for(var i=1; i<arr.length; i++){
5 if(arr[i] < smallest){
6 smallest = arr[i];
7 }
8}
9
10console.log(smallest);
11