{"ScriptPreparationCode":null,"TestCases":[{"Name":"Flatten array with nested reduce and spread operator","Code":"const things = [{\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}, {\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}, {\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}, {\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}];\r\nconst flatValues = things.reduce((acc, current) =\u003E {\r\n const nestedValues = current.nestedThings.reduce((acc2, current2) =\u003E {\r\n \treturn [...acc2, ...current2.key]\r\n }, []);\r\n \r\n\treturn [...acc, ...nestedValues]\r\n}, [])","IsDeferred":false},{"Name":"Flatten array with object assignment and forEach","Code":"const things = [{\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}, {\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}, {\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}, {\r\n nestedThings: [{\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }, {\r\n key: \u0027value\u0027\r\n }]\r\n}];\r\n\r\nconst valuesRecord = things.reduce((acc, current, index) =\u003E {\r\n\tconst nestedValues = current.nestedThings.forEach((nestedThing, index2) =\u003E {\r\n \tacc[\u0060${index}-${index2}\u0060] = nestedThing.key;\r\n })\r\n return acc;\r\n}, {});","IsDeferred":false}]}