I have 2 arrays
One is an array that contains every project:
let allProjects = [{project_id: 1, name: "project 1"}, {project_id: 2, name: "project 2"}, {project_id: 3, name: "project 3"}, {project_id: 4, name: "project 4"}]
And one contains only project ids
let selectedProjects = [{project_id: 1}, {project_id: 2}]
How can I get the names from allProjects array and return a new array containing name and id according to the Id's that are provided in the selectedProjects array?