`;
resultsContainer.appendChild(countryEl);
});
resultsWrapper.classList.remove('hidden');
}
// --- UTILITY FUNCTIONS ---
function formatCurrency(amount, currencyCode) {
try {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: currencyCode, minimumFractionDigits: 2 }).format(amount);
} catch (e) {
return `$${amount.toFixed(2)}`;
}
}
function calculateDuration() {
if (!state.startDate || !state.endDate) return 0;
const start = new Date(state.startDate);
const end = new Date(state.endDate);
if (start > end) return 0;
const diffTime = Math.abs(end - start);
return Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1;
}
// --- START THE APP ---
init();
});
