break the code from example.html into a js file