solution for Arrays exercise 3