My first attempt at building a program in JavaScript