updated the forEach function

changed the for each to store the arr.length as a variable in the for loop.