solution for Arrays exercise 2