Completing the exercises from Eloquent Javascript book