iterate over arrays using i<length approach, to prevent issues with iteration including method properties such as max()