I have a file called events.json which I require then use .map to create my object,
var data = require('./events.json')
var newEventList = data.events.map(events => ({
id: events.id ,
name: events.name ,
venue: events.venue.name
}));
However, sometimes on occasion I get two event.ids which are identical. In these instances the map method creates a duplicate entry in my newEventList object. Can I set a conditional within the map function to skip the 'mapping' of that entry if the ids are identical?
One thing to add is that the duplicates always are consecutive in the events.json so the If statement would only be comparing the previously mapped item.
Thanks for your help.