Some code written while learning Javascript