{"ScriptPreparationCode":"var mixedArray = [];\r\nfor (var i = 0; i \u003C 10000; i\u002B\u002B) {\r\n mixedArray.push({\r\n first: Math.random() \u003E 0.5 ? \u0060first${i}\u0060 : undefined,\r\n second: Math.random() \u003E 0.5 ? Date.now() : undefined\r\n });\r\n}\r\n","TestCases":[{"Name":"Default","Code":"function defaultSort(a) {\r\n const b = a\r\n .map((c, d) =\u003E ({ c, originalIndex: d }))\r\n .filter(({ c }) =\u003E c.first !== undefined);\r\n if (!b.length) return [];\r\n const c = b.filter(({ c }) =\u003E c.second !== undefined);\r\n if (!c.length) return [];\r\n if (c.length === b.length) return [];\r\n return b.map(({ originalIndex }) =\u003E originalIndex);\r\n}","IsDeferred":false},{"Name":"reducer","Code":"function reducer(a) {\r\n return a.reduce((acc, c, i) =\u003E {\r\n if (c.first !== undefined \u0026\u0026 c.second === undefined) {\r\n acc.push(i);\r\n }\r\n return acc;\r\n }, []);\r\n}","IsDeferred":false},{"Name":"forLoop","Code":"function forLoop(a) {\r\n let result = [];\r\n for (let i = 0; i \u003C a.length; i\u002B\u002B) {\r\n if (a[i].first !== undefined \u0026\u0026 a[i].second === undefined) {\r\n result.push(i);\r\n }\r\n }\r\n return result;\r\n}\r\n","IsDeferred":false},{"Name":"Foreach","Code":"function forEachMethod(arr) {\r\n let result = [];\r\n arr.forEach((item, index) =\u003E {\r\n if (item.first !== undefined \u0026\u0026 item.second === undefined) {\r\n result.push(index);\r\n }\r\n });\r\n return result;\r\n}\r\n","IsDeferred":false},{"Name":"Filter","Code":"function filterMethod(arr) {\r\n return arr\r\n .map((item, index) =\u003E (item.first !== undefined \u0026\u0026 item.second === undefined) ? index : -1)\r\n .filter(index =\u003E index !== -1);\r\n}\r\n","IsDeferred":false},{"Name":"Reduce with object","Code":"function reduceObject(arr) {\r\n return arr.reduce((acc, curr, i) =\u003E {\r\n if (curr.first !== undefined \u0026\u0026 curr.second === undefined) {\r\n acc.push(i);\r\n }\r\n return acc;\r\n }, []);\r\n}\r\n","IsDeferred":false}]}