I have below object and need to delete the column from the result, I will get the column name dynamically. Could you please help me how to delete the column and its corresponding object based on column name {"columnname":"couln2", "datatype":null}
Array is:
{
"tabl1":
{"tablename":"tabl1","tablecolumns":"yes","patternCheckStatus":true,
"columns": [{"columnname":"column1","datatype":"Numeric","patternregex":"jjj"},{"columnname":"column2","datatype":"UpperCase","patternregex":"hkl;;"}]},
"table2":{"tablename":"table2","tablecolumns":"yes","patternCheckStatus":null,
"columns":[{"columnname":"t2column","datatype":"Alphabetic"}]
}}
let arr =
{"tabl1":{"tablename":"tabl1","tablecolumns":"yes","patternCheckStatus":true,"columns":[{"columnname":"column1","datatype":"Numeric","patternregex":"jjj"},{"columnname":"column2","datatype":"UpperCase","patternregex":"hkl;;"}]},"table2":{"tablename":"table2","tablecolumns":"yes","patternCheckStatus":null,"columns":[{"columnname":"t2column","datatype":"Alphabetic"}]}}
const result = arr.reduce((a, {tablename, tablecolumns, columnname, datatype}) => {
a[tablename] = a[tablename] || {tablename, tablecolumns, columns: []};
if (columnname)
a[tablename].columns.push({columnname, datatype});
return a;
},{})
console.log(Object.values(result));