Solution Review: Find the Minimum in an Array
This lesson explains the solution for the find the minimum in an array exercise.
We'll cover the following...
Solution
Press + to interact
let arr = [| 23, 45, 17, 10, 60, 54 |];let findMin = (arr: array(int)) => {let min = ref(-1);min := arr[0]; /* Start with the first value of the array */for (i in 1 to Array.length(arr)-1) { /* Travrse the array */if (min^ > arr[i]) { /* Whenever a value smaller than min is found */min := arr[i]; /* Make it the new min */};};min^;};Js.log(findMin(arr));
Explanation
The for
...