diff --git a/ejercicio5/ejercicio5.js b/ejercicio5/ejercicio5.js index 6ce9e92..e4ebf64 100644 --- a/ejercicio5/ejercicio5.js +++ b/ejercicio5/ejercicio5.js @@ -1 +1,45 @@ // Agregar aquí el código javascript + +const countries = [ + 'Argentina', + 'Brasil', + 'Chile', + 'Colombia', + 'Ecuador', + 'Perú', + 'Uruguay', + 'Venezuela', + 'Paraguay', + 'Bolivia', + 'Panamá', + 'Costa Rica', + 'Cuba', + 'República Dominicana', + 'Guatemala', + 'Honduras', + 'El Salvador', + 'Nicaragua', + 'Puerto Rico', + 'México', + 'Estados Unidos', + 'Canadá', + 'Guayana', + 'Surinam', + 'Guyana Francesa', +]; + +document.getElementById('search').addEventListener('input', () => { + const query = document.getElementById('search').value.toLowerCase(); + const resultsList = document.getElementById('resultsList'); + resultsList.innerHTML = ''; + + const filteredCountries = countries.filter(country => + country.toLowerCase().includes(query) + ); + + filteredCountries.forEach(country => { + const li = document.createElement('li'); + li.textContent = country; + resultsList.appendChild(li); + }); +}); \ No newline at end of file diff --git a/ejercicio5/index.html b/ejercicio5/index.html index 51c5f8b..16962be 100644 --- a/ejercicio5/index.html +++ b/ejercicio5/index.html @@ -8,7 +8,11 @@