Task of Challenge #13/54
Find the maximum number in an array of numbers.
The array: [-21, 113, -34, 1, -9, 5, 99, 1, 0].
To accomplish our task, we create a function called
findMax() and pass in our array.
Inside the body, we need to create a variable referencing our found maximum value. We set the variable
max to the first element of our array. Since this it the first maximum existing. We didn’t check any other so far.
The next step is to loop over the array and check if the element we are currently looking at is greater than our current max value.
If so, replace it to the newly found maximum element of
Once, we are done with iterating, comparing, and adding, just return the found maximum and print it to the console, and you are done!