finished exercise using javascript event listeners and functions