add js solution for problem 8