Completed chapter 2 exercises of Eloquent Javascript