Skip to content

Instantly share code, notes, and snippets.

@kickboxer
Created October 3, 2016 14:00
Show Gist options
  • Save kickboxer/abed5b29f6d3a3fd55e0a6ee254d4498 to your computer and use it in GitHub Desktop.
Save kickboxer/abed5b29f6d3a3fd55e0a6ee254d4498 to your computer and use it in GitHub Desktop.
Создать новый массив с объектами с уникальными свойствами
var districts = [];
function removeDuplicateDistricts(cities) {
for (let i = 0; i < cities.length; i++) {
if (districts.length === 0) {
districts.push(cities[0]);
} else {
var uniqueDistrict = true;
districts.forEach(function(dist) {
if (cities[i].Region == dist.Region && cities[i].District == dist.District) {
uniqueDistrict = false;
}
});
if (uniqueDistrict) {
districts.push(cities[i]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment