Change String Encoding Leetcode Javascript