add complete js solution to problem 27