Hi all, Please help

Please someone help. I’m in a programing course at my local college. I need to find the minimum number of an array. It’s in Khan academy. I have no freaking idea how to do it. Any help is appreciated.

2 Likes

This is a common example, iterating the array and comparing the index value if its lower than the last one.

let array = [5,5,4,2,10,15]

let result = 20;
for(let i=0;i<=array.length;i++){
  if(array[i] < result) result = array[i];
}
console.log("minimun is: ", result);

Carlos Z

you didn’t mention the language. this one will work on jquery. its a built in function.

var _array = [1,3,2];
Math.min.apply(Math,_array);

1 Like