I have an array of JavaScript objects structured as follows:
let users = [{
"id": 9,
"name": "Sulaymon",
"family": "Yahyaei",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="deadabb2bfa7b3b1b0b6b99ebbaab2b9acf0bdb1b3">[email protected]</a>",
"tel": "(91) 247-52-15",
"isActive": 0,
"level": "User",
"email_verified_at": null,
"created_at": "2019-10-30 04:56:18",
"updated_at": "2019-10-30 04:56:18"
}, {
"id": 8,
"name": "Rasul",
"family": "Irmatov",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="77251604021b3712031b10055914181a">[email protected]</a>",
"tel": "(91) 524-57-96",
"isActive": 0,
"level": "User",
"email_verified_at": null,
"created_at": "2019-10-24 12:28:45",
"updated_at": "2019-10-24 12:28:45"
}]
I want to extract an array of objects from my Column object :
let columns = [
{label: 'Name', name: 'name', show: true},
{label: 'Family', name: 'family', show: true},
{label: 'Email', name: 'email', show: true},
{label: 'Telephone', name: 'tel', show: true},
{label: 'Level', name: 'level', show: true},
{label: 'Date Added', name: 'created_at', show: false},
{label: 'Email Verification', name: 'email_verified_at',show: false},
{label: 'Updated At', name: 'updated_at', show: false},
{label: 'Status', name: 'isActive', show: false},
];
If the show property is set to true, then include it in the result, which should look like this :
let userData = [{
"name": "Sulaymon",
"family": "Yahyaei",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2754524b465e4a48494f406742534b40550944484a">[email protected]</a>",
"tel": "(91) 247-52-15",
"level": "User"
}, {
"name": "Rasul",
"family": "Irmatov",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="491b283a3c25092c3d252e3b672a2624">[email protected]</a>",
"tel": "(91) 524-57-96",
"level": "User"
}]
What steps should I take next?