problem solving with js