{"ScriptPreparationCode":"function sortThings(a, b) {\r\nif (a \u003E b) {\r\n return 1\r\n } else if (a \u003C b) {\r\n return -1\r\n } else {\r\n return 0\r\n }\r\n}\r\n\r\nfunction isAnagram(a, b, strict = false) {\r\n return a.length === b.length ? strict ? isStrictAnagram(a, b) : isStrictAnagram(a.toLowerCase(), b.toLowerCase()) : false\r\n}\r\n\r\nfunction isStrictAnagram(a, b) {\r\n return JSON.stringify(a.split(\u0027\u0027).sort(sortThings)) === JSON.stringify(b.split(\u0027\u0027).sort(sortThings))\r\n}\r\n\r\nconst goPex = (stringOne, stringTwo) =\u003E {\r\n const charMap1 = new Map();\r\n const charMap2 = new Map();\r\n\r\n if (stringOne.length !== stringTwo.length) return false;\r\n for (let i = 0; i \u003C stringOne.length; i\u002B\u002B) {\r\n charMap1.set(stringOne[i], (charMap1.get(stringOne[i]) || 0) \u002B 1);\r\n charMap2.set(stringTwo[i], (charMap2.get(stringTwo[i]) || 0) \u002B 1);\r\n }\r\n\r\n for ([key, value] of charMap1) {\r\n if (value !== charMap2.get(key)) return false;\r\n }\r\n return true;\r\n};\r\n\r\nconst ana = (one, two) =\u003E {\r\n const r = (str) =\u003E str.split(\u0027\u0027).reduce((acc, item) =\u003E {\r\n if (acc.hasOwnProperty(item)) {\r\n acc[item]\u002B\u002B\r\n } else {\r\n acc[item] = 1\r\n }\r\n return acc\r\n }, {})\r\n const target = {}\r\n Object.keys(r(one)).sort().map(item =\u003E target[item] = r(one)[item])\r\n const comparator = {}\r\n Object.keys(r(two)).sort().map(item =\u003E comparator[item] = r(two)[item])\r\n return JSON.stringify(target) === JSON.stringify(comparator)\r\n}","TestCases":[{"Name":"test1","Code":"\r\nfunction test1() {\r\nconsole.log(isAnagram(\u0027abc\u0027, \u0027bca\u0027))\r\nconsole.log(isAnagram(\u0027foo\u0027, \u0027ofoo\u0027))\r\nconsole.log(isAnagram(\u0027ooffoo\u0027, \u0027ffooff\u0027))\r\nconsole.log(isAnagram(\u0027\u0027, \u0027\u0027))\r\nconsole.log(isAnagram(\u0027\u0027, \u0027bca\u0027))\r\nconsole.log(isAnagram(\u0027\u0027, \u0027bca\u0027))\r\n}","IsDeferred":false},{"Name":"test2","Code":"function test2() {\r\nconsole.log(ana(\u0027abc\u0027, \u0027bca\u0027))\r\nconsole.log(ana(\u0027foo\u0027, \u0027ofoo\u0027))\r\nconsole.log(ana(\u0027ooffoo\u0027, \u0027ffooff\u0027))\r\nconsole.log(ana(\u0027\u0027, \u0027\u0027))\r\nconsole.log(ana(\u0027\u0027, \u0027bca\u0027))\r\nconsole.log(ana(\u0027\u0027, \u0027bca\u0027))\r\n}","IsDeferred":false},{"Name":"test3","Code":"function test3() {\r\nconsole.log(goPex(\u0027abc\u0027, \u0027bca\u0027))\r\nconsole.log(goPex(\u0027foo\u0027, \u0027ofoo\u0027))\r\nconsole.log(goPex(\u0027ooffoo\u0027, \u0027ffooff\u0027))\r\nconsole.log(goPex(\u0027\u0027, \u0027\u0027))\r\nconsole.log(goPex(\u0027\u0027, \u0027bca\u0027))\r\nconsole.log(goPex(\u0027\u0027, \u0027bca\u0027))\r\n}","IsDeferred":false}]}