Issue looping an integer array to get a max number

Hi guys, am trying to use the above method to loop through an array of int and get the maximum big number, my function loop only gets me the first value. Anyone who can assist me to figure this out?

To figure it out you could use the debugger or even a dry run.
You return maxNumber for “each” iteration so you’ll leave the method after the first iteration.

Also review your variables and variable names. E.g. what is iMax for? Did you consider that there might be only negative values in the array or none at all?

1 Like

So I managed to debug the code and did the necessary changes it’s now working, thanks for the tip, Sam.