Created downloadCSV function

Organized the JavaScript into a function named downloadCSV for easier
instantiation.