Javascript Solution
Solution 1:\n\n\n/**\n * @param {string} S\n * @param {string} T\n * @return {boolean}\n */\nvar backspaceCompare = function(S, T) {\n    return backSpace(S) ==
Solution 1:\n\n```\n/**\n * @param {string} S\n * @param {string} T\n * @return {boolean}\n */\nvar backspaceCompare = function(S, T) {\n    return backSpace(S) === backSpace(T)\n};\n\nconst backSpace = (str) => {\n    const result = []\n    for (let i = 0; i < str.length; i++) {\n        const char = str.charAt(i)\n        if (char !== \'#\') result.push(char)\n        else result.pop()\n    }\n    return result.join(\'\')\n}\n```\n\nSolution 2:\n\n```\n/**\n * @param {string} S\n * @param {string} T\n * @return {boolean}\n */\nvar backspaceCompare = function(S, T) {\n    return compare(S) === compare(T)\n};\n\nconst compare = (word) => {\n    while (word.includes(\'#\')) {\n        const index = word.indexOf(\'#\')\n        if (index > -1) word = word.substr(0, index-1) + word.slice(index+1)\n    }\n    return word\n}\n```
[]