{"ScriptPreparationCode":null,"TestCases":[{"Name":"ff","Code":"const text = \u0022hello worldbb\u0022;\r\nfunction count(string){\r\n let a_counter = 0;\r\n let b_counter = 0;\r\n let sp = string.split(\u0027\u0027)\r\n sp.forEach(function(aa){\r\n if(aa == \u0027a\u0027){\r\n a_counter = a_counter \u002B 1\r\n }\r\n if(aa == \u0027b\u0027){\r\n b_counter = b_counter \u002B 1\r\n }\r\n })\r\n if(!string) {\r\n return {};\r\n } else if(b_counter \u003E 0 \u0026\u0026 a_counter \u003E 0){\r\n return {a: a_counter, b: b_counter}\r\n } else if(b_counter \u003E 0 \u0026\u0026 a_counter == 0){\r\n return {b: b_counter}\r\n } else {\r\n return {a: a_counter}\r\n }\r\n}\r\n\r\ncount(text);\r\n","IsDeferred":false},{"Name":"ss","Code":"const text = \u0022hello worldbb\u0022;\r\nconst count = (text) =\u003E {\r\n const allowedCharacters = [\u0022a\u0022, \u0022b\u0022];\r\n\r\n return [...text].reduce((accumulator, currentValue) =\u003E {\r\n if (allowedCharacters.includes(currentValue)) accumulator[currentValue] = (accumulator[currentValue] || 0) \u002B 1;\r\n return accumulator;\r\n }, {});\r\n};\r\n\r\ncount(text);","IsDeferred":false}]}