Could someone assist me in creating a function that finds the lowest number in an array? I've been struggling with this and previous answers on similar questions didn't really help as they presented solutions with unfamiliar code. The current code I have only returns "0" instead of the expected value of 80. Can anyone provide guidance on how to fix this issue?
var numbers = [100, 90, 100, 80];
function findLowestNumber(arr) {
let lowestNum = arr[0];
for (let i = 1; i < arr.length; i++) {
if (arr[i] < lowestNum) {
lowestNum = arr[i];
}
}
return lowestNum;
}
console.log(findLowestNumber(numbers));