created for loop to loop through array