Completing the end-of-chapter exercises from Eloquent JavaScript