refactored functions so that there are not variables or function calls in the global scope.
creating arrays in javascript, calculating length, and accessing different items in the array
created a for and a foreach loop to iterate through the names array