{"ScriptPreparationCode":null,"TestCases":[{"Name":"one liner","Code":"const peopleArray = [\r\n { id: 123, name: \u0022dave\u0022, age: 23 },\r\n { id: 456, name: \u0022chris\u0022, age: 23 },\r\n { id: 789, name: \u0022bob\u0022, age: 23 },\r\n { id: 101, name: \u0022tom\u0022, age: 23 },\r\n { id: 102, name: \u0022tim\u0022, age: 23 }\r\n]\r\nconst arrayToObject = (arr, keyField) =\u003E\r\n Object.assign({}, ...arr.map(item =\u003E ({[item[keyField]]: item})))\r\nconst peopleObject = arrayToObject(peopleArray, \u0022id\u0022)","IsDeferred":false},{"Name":"reduced","Code":"const peopleArray = [\r\n { id: 123, name: \u0022dave\u0022, age: 23 },\r\n { id: 456, name: \u0022chris\u0022, age: 23 },\r\n { id: 789, name: \u0022bob\u0022, age: 23 },\r\n { id: 101, name: \u0022tom\u0022, age: 23 },\r\n { id: 102, name: \u0022tim\u0022, age: 23 }\r\n]\r\nconst arrayToObject = (array, keyField) =\u003E\r\n array.reduce((obj, item) =\u003E {\r\n obj[item[keyField]] = item\r\n return obj\r\n }, {})\r\nconst peopleObject = arrayToObject(peopleArray, \u0022id\u0022)","IsDeferred":false},{"Name":"reduced clean","Code":"const peopleArray = [\r\n { id: 123, name: \u0022dave\u0022, age: 23 },\r\n { id: 456, name: \u0022chris\u0022, age: 23 },\r\n { id: 789, name: \u0022bob\u0022, age: 23 },\r\n { id: 101, name: \u0022tom\u0022, age: 23 },\r\n { id: 102, name: \u0022tim\u0022, age: 23 }\r\n]\r\nconst arrayToObject = (array, keyField) =\u003E\r\n array.reduce((acc, curr) =\u003E ({ [curr[keyField]]: curr, ...acc }), {})\r\nconst peopleObject = arrayToObject(peopleArray, \u0022id\u0022)","IsDeferred":false}]}