Making JavaScript logic work with the front end