{"ScriptPreparationCode":null,"TestCases":[{"Name":"METHOD MANIA","Code":"const fruits = [\u0022apple\u0022, \u0022orange\u0022, \u0022apple\u0022, \u0022peach\u0022, \u0022pear\u0022, \u0022apple\u0022, \u0022peach\u0022]\r\nconsole.log(highestFrequencyString(fruits)); // \u0022apple appears 3 times in the array.\u0022\r\nconst highestFrequencyString = (strArray) =\u003E {\r\n let res = {};\r\n strArray.forEach((str) =\u003E (res[str]) ? res[str]\u002B\u002B : res[str]=1);\r\n // var reuse because i\u0027m a degenerate\r\n res = Object.entries(res).sort((a,b) =\u003E b[1]-a[1])[0];\r\n return \u0060${res[0]} appears ${res[1]} times in the array.\u0060\r\n}","IsDeferred":false},{"Name":"FOR LOOP MANIA","Code":"const fruits = [\u0022apple\u0022, \u0022orange\u0022, \u0022apple\u0022, \u0022peach\u0022, \u0022pear\u0022, \u0022apple\u0022, \u0022peach\u0022]\r\nconsole.log(highestFrequencyString(fruits)); // \u0022apple appears 3 times in the array.\u0022\r\nconst highestFrequencyString = (strArray) =\u003E {\r\n strArray.sort((a,b) =\u003E a \u003C= b ? -1 : 1);\r\n let max = 0;\r\n let curr = 0;\r\n let res;\r\n for (let i = 0; i \u003C strArray.length-1; i\u002B\u002B) {\r\n if (strArray[i] === strArray[i\u002B1]) {\r\n curr\u002B\u002B;\r\n } else {\r\n curr\u002B\u002B;\r\n if (max \u003C curr) {\r\n max = curr;\r\n res = strArray[i];\r\n }\r\n curr = 0;\r\n }\r\n }\r\n return \u0060${res} appears ${max} times in the array.\u0060\r\n}","IsDeferred":false}]}