Modified array using for and forEach