solved exercise 3 from arrays