{"ScriptPreparationCode":"var arr = {\r\n x: [{\r\n id: 1,\r\n label: \u0022a\u0022,\r\n type: \u0022x\u0022\r\n }, {\r\n id: 2,\r\n label: \u0022b\u0022,\r\n type: \u0022x\u0022\r\n }, {\r\n id: 3,\r\n label: \u0022c\u0022,\r\n type: \u0022x\u0022\r\n }],\r\n y: [{\r\n id: 4,\r\n label: \u0022d\u0022,\r\n type: \u0022y\u0022\r\n }, {\r\n id: 5,\r\n label: \u0022e\u0022,\r\n type: \u0022y\u0022\r\n }, {\r\n id: 6,\r\n label: \u0022f\u0022,\r\n type: \u0022y\u0022\r\n }],\r\n z: [{\r\n id: 7,\r\n label: \u0022g\u0022\r\n }]\r\n};","TestCases":[{"Name":"With splice","Code":"const option = {value:3, label:\u0022c\u0022};\r\nconst comparator = ({id}, index, array) =\u003E {\r\n if(id === option.value){\r\n array.splice(index, 1);\r\n return true;\r\n } \r\n }\r\n const x = [...arr.x];\r\n const y = [...arr.y];\r\n const property = x.find(comparator) || y.find(comparator);\r\n const z = [...arr.z]\r\n z.push({ ...property, value: \u0027\u0027, errorMessage: \u0027\u0027 });\r\n const obj = {x,y,z}; \r\n","IsDeferred":false},{"Name":"With filter","Code":"const option = {value:3, label:\u0022c\u0022};\r\n const comparator = ({id}, index, array) =\u003E {\r\n if(id === option.value){\r\n return true;\r\n } \r\n }\r\nconst property = arr.x.find(comparator) || arr.y.find(comparator);\r\nconst list = arr[property.type].filter(option =\u003E option.id !== property.id);\r\nconst z = [...arr.z];\r\nz.push({ ...property, value: \u0027\u0027, errorMessage: \u0027\u0027 });\r\nconst obj = {...arr, z, [property.type]: list};","IsDeferred":false}]}