JS solution for problem 2