{"ScriptPreparationCode":"var demoStr = \u0027This is a demo of a long string with multiple spaces occasionally added throughout it.\u0027;\r\n\r\nfunction regexReplace(str) {\r\n return str.replace(/\\s\u002B/g, \u0027 \u0027);\r\n};\r\n\r\nfunction arrayReplace(str) {\r\n let resultArr = [];\r\n const strArr = str.split(\u0027 \u0027);\r\n for (let i = 0; i \u003C strArr.length; i\u002B\u002B) {\r\n if (strArr[i] != \u0027\u0027) {\r\n resultArr.push(strArr[i]);\r\n }\r\n }\r\n return resultArr.join(\u0027 \u0027);\r\n};\r\n\r\nfunction collapseSpaces(s) {\r\nlet result = \u0027\u0027;\r\n for (let i = 0; i \u003C s.length; i\u002B\u002B) {\r\n \tconst c = s.charAt(i);\r\n result \u002B= c;\r\n \tif (c === \u0027 \u0027) {\r\n \twhile (i \u003C s.length - 1 \u0026\u0026 s.charAt(i \u002B 1) === \u0027 \u0027) {\r\n \ti\u002B\u002B;\r\n }\r\n }\r\n }\r\n return result;\r\n}","TestCases":[{"Name":"regexReplace","Code":"regexReplace(demoStr)","IsDeferred":false},{"Name":"arrayReplace","Code":"arrayReplace(demoStr)","IsDeferred":false},{"Name":"collapseSpaces","Code":"collapseSpaces(demoStr)","IsDeferred":false}]}