refactoring code using JavaScript Best Practices and adding .jshintrc