A javascript exercise I completed as part of a job application