Added JS solution to problem 3.