Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const countries = [
+ 'Poland', 'Germany', 'France', 'Spain', 'Italy', 'United Kingdom',
+ 'United States', 'Canada', 'Japan', 'China', 'Australia', 'Brazil'
+ ];
+
+ const economicJokes = [
+ "Why did the economist bring a ladder to tea? Because he expected a steep inflation!",
+ "What did the GDP say to the recession? 'Stop bringing me down!'",
+ "Why don't economists look out the window in the morning? Because they'd have nothing to do in the afternoon!",
+ "What's an economist's favorite holiday? Taxmas!",
+ "Why did the economy cross the road? For supply and demand reasons!"
+ ];
+
+ // Populate country dropdowns
+ const populateDropdowns = () => {
+ const dropdowns = [document.getElementById('country1'), document.getElementById('country2')];
+ dropdowns.forEach(dropdown => {
+ countries.forEach(country => {
+ const option = document.createElement('option');
+ option.value = country.toLowerCase();
+ option.textContent = country;
+ dropdown.appendChild(option);
+ });
+ });
+ };
+
+ // Generate random economic data
+ const generateData = () => {
+ return {
+ gdp: (Math.random() * 20 + 1).toFixed(2),
+ inflation: (Math.random() * 10).toFixed(1),
+ unemployment: (Math.random() * 15).toFixed(1),
+ debt: (Math.random() * 150).toFixed(1)
+ };
+ };
+
+ // Compare countries
+ const compareCountries = (e) => {
+ e.preventDefault();
+ const country1 = document.getElementById('country1').value;
+ const country2 = document.getElementById('country2').value;
+ const metric = document.getElementById('metric').value;
+
+ if (!country1 || !country2) {
+ alert('Please select both countries');
+ return;
+ }
+
+ const data1 = generateData();
+ const data2 = generateData();
+
+ const country1Data = document.getElementById('country1Data');
+ const country2Data = document.getElementById('country2Data');
+
+ country1Data.innerHTML = `
+
${country1.toUpperCase()}
+
${metric.toUpperCase()}: ${data1etric]}%
+ `;
+
+ country2Data.innerHTML = `
+
${country2.toUpperCase()}
+
${metric.toUpperCase()}: ${data2etric]}%
+ `;
+
+ // Show random joke
+ const jokeElement = document.getElementById('joke');
+ jokeElement.textContent = economicJokes[Math.floor(Math.random() * economicJokes.length)];
+
+ // Show results
+ document.querySelector('.results').classList.remove('hidden');
+ };
+
+ // Initialize
+ populateDropdowns();
+ document.getElementById('compareBtn').addEventListener('click', compareCountries);
+ });