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 array.

Once, we are done with iterating, comparing, and adding, just return the found maximum and print it to the console, and you are done!

Follow me on Instagram and don’t miss the latest Challenge!


Become a bullet proof developer and seek my coding adventures on Udemy


Don’t miss two of my most read Medium Articles