{"ScriptPreparationCode":"window.input = \u0027This is an aexample of a templated literal supported in modern JavaScript: \u0060test ${test}\u0060.\u0027\r\n\r\nwindow.stringifyByConcatWithSwitch = str =\u003E {\r\n let res = \u0027\u0027;\r\n for (let i = 0, l = str.length; i \u003C l; \u002B\u002Bi) {\r\n let chr = str.charAt(i);\r\n switch (chr) {\r\n case \u0027\\\\\u0027: chr = \u0027\\\\\\\\\u0027; break\r\n case \u0027\u0060\u0027: chr = \u0027\\\\\u0060\u0027; break\r\n case \u0027$\u0027: chr = \u0027\\\\$\u0027; break\r\n }\r\n res \u002B= chr\r\n }\r\n return \u0060\\\u0060${res}\\\u0060\u0060\r\n}\r\n\r\nwindow.stringifyByRegex = str =\u003E str.replace(/\\\\|\u0060|\\$(?={)/g, match =\u003E \u0060\\\\${match}\u0060)\r\n\r\nwindow.stringifyByJoin = str =\u003E {\r\n let res = [];\r\n for (let i = 0, l = str.length; i \u003C l; \u002B\u002Bi) {\r\n let chr = str.charAt(i)\r\n switch (chr) {\r\n case \u0027\\\\\u0027: chr = \u0027\\\\\\\\\u0027; break\r\n case \u0027\u0060\u0027: chr = \u0027\\\\\u0060\u0027; break\r\n case \u0027$\u0027: chr = \u0027\\\\$\u0027; break\r\n }\r\n res.push(chr)\r\n }\r\n return \u0060\\\u0060${res.join()}\\\u0060\u0060\r\n}\r\n\r\nconst escaped = {\r\n \u0027\\\\\u0027: \u0027\\\\\\\\\u0027,\r\n \u0027\u0060\u0027: \u0027\\\\\u0060\u0027,\r\n \u0027$\u0027: \u0027\\\\$\u0027\r\n}\r\n\r\nwindow.stringifyByConcatWithObject = str =\u003E {\r\n let res = \u0027\u0027\r\n for (let i = 0, l = str.length; i \u003C l; \u002B\u002Bi) {\r\n let chr = str.charAt(i)\r\n res \u002B= escaped[chr] || chr\r\n }\r\n return \u0060\\\u0060${res}\\\u0060\u0060\r\n}\r\n\r\nwindow.stringifyByConcatWithIf = str =\u003E {\r\n let res = \u0027\u0027;\r\n for (let i = 0, l = str.length; i \u003C l; \u002B\u002Bi) {\r\n let chr = str.charAt(i)\r\n if (chr === \u0027\\\\\u0027) chr = \u0027\\\\\\\\\u0027\r\n else if (chr === \u0027\u0060\u0027) chr = \u0027\\\\\u0060\u0027\r\n else if (chr === \u0027$\u0027) chr = \u0027\\\\$\u0027\r\n res \u002B= chr\r\n }\r\n return \u0060\\\u0060${res}\\\u0060\u0060\r\n}\r\n","TestCases":[{"Name":"concatenating with switch","Code":"stringifyByConcatWithSwitch(input)","IsDeferred":false},{"Name":"regex replacement","Code":"stringifyByRegex(input)","IsDeferred":false},{"Name":"array joining","Code":"stringifyByJoin(input)","IsDeferred":false},{"Name":"concatenating with object","Code":"stringifyByConcatWithObject(input)","IsDeferred":false},{"Name":"concatenating with if","Code":"stringifyByConcatWithIf(input)","IsDeferred":false}]}