A JavaScript based solution to problem 15.