abstracted inline js from index.html to index.js