refactor javascript excercises