Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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)
Comment

find smallest number in array javascript using for loop

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);
Comment

how to find smallest number in array js

Array.min = function( array ){
    return Math.min.apply( Math, array );
};
Comment

find second smallest number in array javascript using for loop

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: react select and react hook form 
Javascript :: convert jquery to string 
Javascript :: how reliable is js hasownproperty 
Javascript :: javascript flatten array of arrays 
Javascript :: popup in browser js 
Javascript :: js unique string array 
Javascript :: Is date greater than 18 years old javascript 
Javascript :: Calculator Function JS Javascript 
Javascript :: bitfield permissions discord,.js 
Javascript :: how to get first and last element of array in javascript 
Javascript :: get ini file with node js 
Javascript :: classlist 
Javascript :: watch file in changes in webpack 
Javascript :: trim() javascript 
Javascript :: mongoose connect to atlas 
Javascript :: javascript check if string contains only numbers 
Javascript :: export multiple functions react 
Javascript :: delete a label jquer 
Javascript :: return object list in find js 
Javascript :: format date in javascript 
Javascript :: node-json-db 
Javascript :: javascript collision detection 
Javascript :: simple js drawing program 
Javascript :: what is redux 
Javascript :: isprime js 
Javascript :: json_decode javascript 
Javascript :: Select radio button through JQuery 
Javascript :: node terminal readline console 
Javascript :: count using sequelize.fn 
Javascript :: object has property 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =