Issue
I want to remove or delete all object where inspectionScheduleQuestionId is null , how do we address this in JS ?
Thanks.
#data
const data = [
{
"id": 0,
"inspectionScheduleQuestionId": 1,
"inspectionScheduleConfirmationId": 0,
"description": "65"
},
{
"id": 0,
"inspectionScheduleQuestionId": 10,
"inspectionScheduleConfirmationId": 0,
"description": "656"
},
{
"id": 0,
"inspectionScheduleQuestionId": null,
"inspectionScheduleConfirmationId": 0,
"description": 6
},
{
"id": 0,
"inspectionScheduleQuestionId": null,
"inspectionScheduleConfirmationId": 0,
"description": 21
},
]
Solution
You can use filter
for this:
const updatedData = data.filter(item => item.inspectionScheduleQuestionId !== null);
Here's some more information on Array.prototype.filter
.
Answered By - Donut
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.