{"ScriptPreparationCode":"var str = \u0027fred red bed said\u0027, searchTerm = \u0027bed\u0027,\r\n arr = str.split(\u0027 \u0027);\r\nfunction removeSubstr(str, substr){\r\n\ttmp = \u0022 \u0022 \u002B str \u002B \u0022 \u0022;\r\n\tsubstr = \u0022 \u0022 \u002B substr \u002B \u0022 \u0022;\r\n\tif (tmp.indexOf(substr) !== -1 ) {\r\n \t\ttmp = tmp.replace(substr, \u0022\u0022).trim(); \r\n \t\treturn tmp\r\n\t}\r\n return str;\r\n}\r\n\r\nfunction removeSubstr2(str, substr){\r\n\tvar len = str.length, tmp = (\u0022 \u0022 \u002B str \u002B \u0022 \u0022).replace(\u0022 \u0022 \u002B substr \u002B \u0022 \u0022, \u0022\u0022).trim(); \r\n\tif ( str.length \u003C len ) return tmp;\r\n \treturn str;\r\n}\r\n\r\nfunction removeSubstr3(str, substr){\r\n var strSpl = str.split(\u0027 \u0027), idx = strSpl.indexOf(substr);\r\n if ( idx \u003E -1) {\r\n return strSpl.splice(idx, 1).join(\u0027 \u0027);\r\n }\r\n return str;\r\n}\r\n\r\nfunction removeElem(arr, substr){\r\n var idx = arr.indexOf(substr);\r\n if ( idx \u003E -1) {\r\n return arr.splice(idx, 1);\r\n }\r\n return arr;\r\n}","TestCases":[{"Name":"String Replace No Compare","Code":"removeSubstr(str, searchTerm)","IsDeferred":false},{"Name":"String Replace With Compare","Code":"removeSubstr2(str, searchTerm)","IsDeferred":false},{"Name":"Convert to Array","Code":"removeSubstr3(str, searchTerm)","IsDeferred":false},{"Name":"Remove From Array","Code":"removeElem(arr, searchTerm)","IsDeferred":false}]}