{"ScriptPreparationCode":null,"TestCases":[{"Name":"METHOD MANIA","Code":"const highestFrequencyString = (strArray) =\u003E {\r\n // so janky can we do better?\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 console.log(\u0060${res[0]} appears ${res[1]} times in the array.\u0060);\r\n}\r\n\r\nconst fruits = [\u0022apple\u0022, \u0022orange\u0022, \u0022apple\u0022, \u0022peach\u0022, \u0022pear\u0022, \u0022apple\u0022, \u0022peach\u0022];\r\nhighestFrequencyString(fruits);","IsDeferred":false},{"Name":"FOR LOOP MANIA","Code":"const 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 if (max \u003C \u002B\u002Bcurr) {\r\n max = curr;\r\n res = strArray[i];\r\n }\r\n curr = 0;\r\n }\r\n }\r\n console.log( \u0060${res} appears ${max} times in the array.\u0060);\r\n}\r\n\r\nconst fruits = [\u0022apple\u0022, \u0022orange\u0022, \u0022apple\u0022, \u0022peach\u0022, \u0022pear\u0022, \u0022apple\u0022, \u0022peach\u0022];\r\nhighestFrequencyString(fruits);","IsDeferred":false}]}