I want to remove all Id from dep_array that exists in the dep_log array and have deleted=0.
//array of departments ID
dep_array=['3', '2', '1'];
dep_log=[{"department_id": "3", "creation_date": "2023-05-13 17:59:27", "created_by": "1", "deleted":"0"} ,
{"department_id": "2", "creation_date": "2023-05-13 17:59:11", "created_by": "1", "deleted":"1"} ,
{"department_id": "1", "creation_date": "2023-05-13 09:46:25", "created_by": "1","deleted":"0"} ]
the reults should be stord in new array the filtered IDs
3
Answers
You can do it via Array.filter() and Array.some()
You can use JavaScript’s array method
filter
to get a sub-array conditionally.Documentation for filter
You may combine the
filter
function withfind
function to get your desired array.