I have called two APIs - that gave me two arrays, is it possible to make one array, but leaving out the values of array b - so I can use the new array in a flatlist in React Native. I have looked around and can see many ways to join the arrays together (this is as far as I can get). And also find and delete duplicated values(but this will leave me with the result that looks exactly like array a) but it's the values that only occur once is what I am after - when they are joined together! So the arrays I can get:
const a = [{"id": "08.30 AM", "title": "08.30 AM"}, {"id": "09.30 AM", "title": "09.30 AM"}, {"id": "10.30 AM", "title": "10.30 AM"}, {"id": "11.30 AM", "title": "11.30 AM"}, {"id": "12.30 AM", "title": "12.30 AM"}, {"id": "14.30 PM", "title": "14.30 PM"}, {"id": "15.30 PM", "title": "15.30 PM"}, {"id": "16.30 PM", "title": "16.30 PM"}]
const b = [{"id": "08.30 AM", "title": "08.30 AM"}, {"id": "11.30 AM", "title": "11.30 AM"}, {"id": "16.30 PM", "title": "16.30 PM"}]
And was hoping to produce this:
const c = [{"id": "09.30 AM", "title": "09.30 AM"}, {"id": "10.30 AM", "title": "10.30 AM"},{"id": "12.30 AM", "title": "12.30 AM"}, {"id": "14.30 PM", "title": "14.30 PM"}, {"id": "15.30 PM", "title": "15.30 PM"}]
If I join the two arrays I would get duplicates I would like to have a new array that would look like array c - I am new so I hope I explained this OK!
I used this to join these together: const c = a.concat(b);
Array a - will always be the same if this helps!