I have two arrays of zip codes. The first array has many zip codes including duplicates. The second array has the duplicates removed to show only the unique zip codes.
How can I check how many times each unique zip code appears in the zip code containing duplicates?
For example, if I have two values for 21218, how can I check that there are two values? I would like to iterate through the unique name array if possible to check against the duplicate name array.
Edit: This question is similar to this previously asked question here. However, it differs because the goal is to use the existing code and incorporate it into the solution.
var url = 'https://data.baltimorecity.gov/resource/uds6-qsb6.json?$limit=50000';
var manyZipArray = [];
var zipArray = [];
$(document).ready(function() {
$.getJSON(url, function(data) {
for (var i = 0; i < data.length; i++) {
manyZipArray.push(data[i].zip);
};
$.each(manyZipArray, function(i, el) {
if ($.inArray(el, zipArray) === -1) zipArray.push(el);
});
zipArray.sort();
for (var i = 0; i < zipArray.length; i++) {
$('#myList').append("<li>" + zipArray[i] + "</li>");
};
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h3 style="text-align: center" ;>Unique Zip Codes </h3>
<ul id="myList"></ul>