{"ScriptPreparationCode":"function shuffle(a) {\r\n var j, x, i;\r\n for (i = a.length; i; i--) {\r\n j = Math.floor(Math.random() * i);\r\n x = a[i - 1];\r\n a[i - 1] = a[j];\r\n a[j] = x;\r\n }\r\n}\r\nvar all = [];\r\nvar ids = [];\r\nvar allLength = 1000;\r\nvar idsLength = 800;\r\n\r\nfor(var i = 0; i \u003C allLength; i\u002B\u002B) {\r\n all[i] = {id: i, value: \u0027value\u0027 \u002B i };\r\n}\r\n\r\nfor(var i = 0; i \u003C allLength; i\u002B\u002B) {\r\n ids[i] = i;\r\n}\r\nids = ids.splice(allLength - idsLength)\r\nshuffle(all);\r\nshuffle(ids);","TestCases":[{"Name":"map \u002B find iterate on ids","Code":"var output = _.map(ids, function(id) {\r\n return _.find(all, { id: id });\r\n});\r\nconsole.log(output);","IsDeferred":false},{"Name":"reduce \u002B includes iterate on all","Code":"var output = _.reduce(all, function(acc, element) {\r\n if(_.includes(ids, element.id)) {\r\n acc.push(element);\r\n }\r\n return acc;\r\n}, []);\r\nconsole.log(output);","IsDeferred":false},{"Name":"filter \u002B includes \u002B map iterate on all","Code":"var output = _.filter(all, function(element) {\r\n return _.includes(ids, element.id);\r\n});\r\nconsole.log(output);","IsDeferred":false}]}