-3

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?

lesterfernandez
  • 216
  • 3
  • 7
  • Does this answer your question? [Find the min/max element of an array in JavaScript](https://stackoverflow.com/questions/1669190/find-the-min-max-element-of-an-array-in-javascript) – General Grievance Nov 07 '22 at 19:44

1 Answers1

1

let arr = [10, 122, 673, 37, 85, 119, 10];
let min=arr[0]
arr.forEach(item=>{if(item <min) min=item})
console.log(min)
jessica-98
  • 609
  • 1
  • 6