I want to remove an object in an array if the object is not included from another array
i have an array of objects
let programs = [
{"id":1,"name":"BSIT","description":"Bachelor of Science in Information Technology","institute":"IC"},
{"id":2,"name":"BSIS","description":"Bachelor of Science in Information System","institute":"IC"},
{"id":3,"name":"BSED","description":"Bachelor of Secondary Education","institute":"ITED"},
{"id":4,"name":"BSAF","description":"BACHELOR OF SCIENCE IN AGRO-FORESTRY","institute":"IAAS"}
]
and i want to remove the objects that exist in this array of objects
let programs2 = [
{"id":1,"name":"BSIT","description":"Bachelor of Science in Information Technology","institute":"IC"},
{"id":2,"name":"BSIS","description":"Bachelor of Science in Information System","institute":"IC"},
{"id":3,"name":"BSED","description":"Bachelor of Secondary Education","institute":"ITED"}
]
both are dynamic and they are fetched from database
i've tried filter but doesn't work.
here is my approach
const ress =ref(programs.filter(element => {
if(programs2.includes(element.id))
{
return element
}
}))
i used axios to fetch data