Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find the smallest number from an array

// smallest number from array
function solution(num) {
  let small = num[0];
  for (let i = 1; i <= num.length; i++) {
    if (small > num[i]) {
      small = num[i]
    }
  }
  console.log("smallest nunber:", small)
}
solution([3, 1, 4, 6, 5, 7, 3, 2,0,-1])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #smallest #number #array
ADD COMMENT
Topic
Name
2+1 =