making progress on problem 16 in javascript