{"ScriptPreparationCode":"function getRandomInt(max) {\r\n return Math.floor(Math.random() * Math.floor(max));\r\n}\r\n\r\nvar testArr = [];\r\nfor (var i = 0; i \u003C 100000; i\u002B\u002B) {\r\n testArr.push({\r\n val: String(getRandomInt(1000))\r\n });\r\n}","TestCases":[{"Name":"Array Unique","Code":"const { resultArray } = testArr.reduce((result, item) =\u003E {\r\n \r\n if(!result.resultMap[item.val]){\r\n result.resultMap[item.val] = true;\r\n result.resultArray.push(item)\r\n }\r\n return result;\r\n}, {resultArray: [], resultMap: {}});\r\n\r\nreturn resultArray;","IsDeferred":false},{"Name":"For Loop","Code":"const resultArray = [];\r\nconst resultMap = {};\r\n\r\nfor(let item of testArr) {\r\n if(!resultMap[item.val]){ \r\n resultMap[item.val] = true;\r\n resultArray.push(item)\r\n }\r\n}\r\n\r\nreturn resultArray;","IsDeferred":false},{"Name":"Array Unique - v2","Code":"const resultObj = testArr.reduce((result, item) =\u003E {\r\n if(!result[item.val]){\r\n result[item.val] = item;\r\n }\r\n return result;\r\n}, {});\r\n\r\nconst resultArray = Object.values(resultObj);\r\nreturn resultArray;","IsDeferred":false},{"Name":"For Loop - v2","Code":"const resultObj = {};\r\n\r\nfor(let item of testArr) {\r\n if(!resultObj[item.val]){ \r\n resultObj[item.val] = item;\r\n }\r\n}\r\n\r\nconst resultArray = Object.values(resultObj);\r\nreturn resultArray;","IsDeferred":false}]}