in index.js [27:45]
async function initializeCountrySelect() {
let countries;
await fetch("data/countries.json")
.then(data => data.json())
.then(json => countries = json);
// Sort countries by name.
countries.sort(function (a, b) {
return a.name.localeCompare(b.name);
});
const locationsSelect = document.getElementById('locations');
for (const country of countries) {
// Store the stringified object as option value.
// Adding the actual values as data- attribute mighe be nicer.
locationsSelect.add(new Option(country.name, JSON.stringify(country)));
}
}