How do I find the lowest number in array using the forEach function in javascript?
Here is an example:
let arr = [10, 122, 673, 37, 85, 119, 10];
How would I use forEach to find the minimum number (in this case 10) in arr
?
How do I find the lowest number in array using the forEach function in javascript?
Here is an example:
let arr = [10, 122, 673, 37, 85, 119, 10];
How would I use forEach to find the minimum number (in this case 10) in arr
?
let arr = [10, 122, 673, 37, 85, 119, 10];
let min=arr[0]
arr.forEach(item=>{if(item <min) min=item})
console.log(min)