I feel like an idiot, but I just can't figure this one out. I'm creating an array of objects:
var files = [];
for (var a = 0; a < data.Attachments.length; a++) {
files.push({
id: data.Attachments[a].ID,
name: data.Attachments[a].Name,
size: data.Attachments[a].Size,
extension: data.Attachments[a].Extension
});
}
And I need to prevent duplicate entries from being added to the array. I've tried a variety of ways to access and check the existing IDs before pushing the new row (including this thread), but nothing has worked. I'm sure it's some little thing I'm just missing.
Here's what a console.log of the files array looks like after it's been populated (it's looping through multiple items and creating an array for each of them; some items don't have attachments):