Lets say I have an array of zipcodes. This is just an example for you to have a clue what I am asking.
zipcodes = [53081, 53083, 54935, 53711, 54935, 53081, 57322, 53083, 53711];
How can I loop through the array only once to output only the unique zipcodes as a HTML list? (53081, 53083, 54935, 53711, 53722)
My code below opens a record set from another file without knowing how many unique zip codes there are. I have it where it outputs all of them.
I am only suppose to output the unique zip codes as a list in HTML.
function zips() {
"use strict";
var zipCodeRecords;
var zipCode;
var uniqueZips;
var output;
uniqueZips = "";
// get the HTML output tag to add list
output = document.getElementById("outputDiv");
// open zipcode records
zipCodeRecords = openZipCodeStudyRecordSet();
while(zipCodeRecords.readNextRecord()) {
zipCode = zipCodeRecords.getSampleZipCode();
uniqueZips += "<li>" + zipCode + "</li>";
}
output.innerHTML = uniqueZips;
}