Javascript Array And String Problems Leetcode