I have an array of objects like this:
// other properties of the object omitted for brevity
// this array can potentially contain upto 50 objects like this
var myArray = [{url: 'http://linkA'}, {url: 'http://linkB'}, {url: 'http://linkA'}]
I am trying to apply the reduce function to create a new object like this:
var newArray = myArray.reduce(function(acc, current, index){
var newObj = {};
newObj['strata'] = 'kit';
newObj['href'] = current['url'];
acc.push(newObj);
return acc;
}, [])
But I do not want to include duplicate objects ('duplicate' tested using 'url' property of the object). How can i modify my reduce function to skip these kinds of objects and produce an
[{strata: kit, href: 'http://linkA'}, {strata: kit, href: 'http://linkB'}]
Edit: Sorry, i forgot to mention that this is legacy code. I cannot use features like 'Set' and 'some'