Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #find #smallest #number #array #javascript #loop
ADD COMMENT
Topic
Name
1+6 =