answered all questions as js functions in the main.js file