Line one. max function is passed the array [4,12,3,8,0,22,56],
Line two. max variable is set to the first item in the array. max is 4,
Line three. A for loop is started which will start from 1 and keep looping for the length of the arr array.
Line four. Checks if the current array value is larger than the max value.
So, first time around it checks if arr[1] is greater then max. If yes, max is set to arr[1]
First loop checks if (12 > 4) it is so max = 12
Second time around it checks if arr[2] is greater than max.
Second loop checks if(3 > 12) it is not so max = 12
Third time around it checks if arr[3] is greater then max.
Third loop checks if (8 > 12) it is not so max = 12
Fourth time around it checks if arr[4] is greater then max.
Fourth loop checks if (0 > 12) it is not so max = 12
Fifth time around it checks if arr[5] is greater then max.
Fifth loop checks if (22 > 12) it is so max = 22
Sixth time around it checks if arr[6] is greater then max.
Sixth loop checks if (56 > 22) it is so max = 56
Line eight. The loop has finished and max is returned. max is 56