const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = Math.min(...arr)
console.log(min)
console.log(Math.min(2, 3, 1));
// expected output: 1
console.log(Math.min(-2, -3, -1));
// expected output: -3
const array1 = [2, 3, 1];
console.log(Math.min(...array1));
// expected output: 1
Array.min = function( array ){
return Math.min.apply( Math, array );
};
function smallestNumber(first, second, third) {
if (first < second && first < third) {
return first;
} else if (second < first && second < third) {
return second;
} else {
return third;
}
}
const num1 = 100;
const num2 = 120;
const num3 = 80;
console.log(smallestNumber(num1, num2, num3));
//Output: 80
var test=[1, 2, 4, 77, 80];
console.log("Smallest number in test: "+Math.floor(Math.min(test)));
Math.ceil(num);
//The ceiling of num: the smallest integer greater than or equal to num
Array.min = function( array ){
return Math.min.apply( Math, array );
};
var minimum = Array.min(array);