I have two arrays that I want to compare. If a specific id occurs in both arrays, then that related object should be pushed into a new array.
Here is the current state of my code
locations: Location[];
allImages: Images[];
specificImages: Images[]
locations.forEach((location) => {
allImages.forEach((img) => {
if(location.id === img.id) { // Here I want to check if a specific id occurs in both arrays
specificImages.push(img);
}
});
})
I am currently working with Angular and this if statment/query is taking place within the combineLatest operator of RxJS. Would be great if there would be a nice Typescript or even RxJS solution for this.