javascript find smallest number in an array
const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = Math.min(...arr)
console.log(min)
javascript find smallest number in an array
const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = Math.min(...arr)
console.log(min)
find smallest number in array js
//Not using Math.min:
const min = function(numbers) {
let smallestNum = numbers[0];
for(let i = 1; i < numbers.length; i++) {
if(numbers[i] < smallestNum) {
smallestNum = numbers[i];
}
}
return smallestNum;
};
how to find smallest number in array js
Array.min = function( array ){
return Math.min.apply( Math, array );
};
js get smallest value of array
Array.min = function( array ){
return Math.min.apply( Math, array );
};
var minimum = Array.min(array);
finding the smallest number in an array javascript
var arr = [5,1,9,5,7];
var smallest = arr[0];
for(var i=1; i<arr.length; i++){
if(arr[i] < smallest){
smallest = arr[i];
}
}
console.log(smallest);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us