{"ScriptPreparationCode":null,"TestCases":[{"Name":"Using map\u002Breverse\u002Bjoin","Code":"const str = \u00221111111\u0022;\r\nstr.split(\u0022\u0022).reverse().map((x,i)=\u003E{\r\n\tif((i \u002B 1) % 3 === 0){\r\n\t\t\treturn \u0022 \u0022\u002Bx;\r\n\t} else {\r\n\t\treturn x;\r\n\t}\r\n}).reverse().join(\u0022\u0022);","IsDeferred":false},{"Name":"Using reduce","Code":"const str = \u00221111111\u0022;\r\nstr\r\n.split(\u0022\u0022)\r\n.reverse()\r\n.reduce((acc, cur, i) =\u003E {\r\n\tif (i === str.length - 1) return (cur \u002B acc);\r\n\treturn (((i \u002B 1) % 3 === 0 ? \u0027 \u0027 : \u0027\u0027)\r\n\t\t\u002B cur \u002B acc);\r\n}\r\n, \u0022\u0022);","IsDeferred":false}]}