Function and while loop added.

Function returning an array and while loop addition.