Created
October 3, 2016 14:00
-
-
Save kickboxer/abed5b29f6d3a3fd55e0a6ee254d4498 to your computer and use it in GitHub Desktop.
Создать новый массив с объектами с уникальными свойствами
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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