diff --git a/ejercicios-clase-8.js b/ejercicios-clase-8.js index aa66974..ee6fb1c 100644 --- a/ejercicios-clase-8.js +++ b/ejercicios-clase-8.js @@ -77,4 +77,29 @@ function cambiarFoto(foto, texto){ const imagen = document.querySelector("#foto"); imagen.setAttribute("src", foto); imagen.setAttribute("alt", texto); +} + +function construirLista(items){ + + const contenedor = document.createElement("div"); + + const titulo = document.createElement("h2"); + titulo.textContent = "Lista dinĂ¡mica"; + + const lista = document.createElement("ul"); + + for (const item of items){ + + const li = document.createElement("li"); + + li.textContent = item; + + lista.appendChild(li); + } + + contenedor.appendChild(titulo); + contenedor.appendChild(lista); + document.body.appendChild(contenedor); + contenedor.classList.add("grupo-comidas"); + return contenedor; } \ No newline at end of file