Add Javascript solution to problem 2