Finished code for day 2: JavaScript