JavaScript with Functions - Variable Scope

Refactored previous code using an IFFE so that there are not variables
or function in the global scope.