diff --git a/ejercicios-clase-8.js b/ejercicios-clase-8.js index 93b4209..3d2f3b7 100644 --- a/ejercicios-clase-8.js +++ b/ejercicios-clase-8.js @@ -77,5 +77,30 @@ const imagen = document.querySelector("img"); console.log(imagen.getAttribute("src")); imagen.setAttribute("src", "foto2.jpg"); -imagen.setAttribute("alt", "locro") -//ejercicio 8 \ No newline at end of file +imagen.setAttribute("alt", "locro"); +//ejercicio 8 + +const arrayComidas = ["Comidas mendocinas", "Sopaipilla", "Vino tinto"]; + +function construirLista(array){ + + const creaDiv = document.createElement("div"); + creaDiv.classList.add("grupo-comidas"); + + const h2 = document.createElement("h2"); + h2.textContent = array[0]; + + creaDiv.appendChild(h2); + + const ul = document.createElement("ul"); + + for (let i = 1; i< array.length; i++){ + + const li = document.createElement("li"); + li.textContent = array[i]; + ul.appendChild(li); + + } + creaDiv.appendChild(ul); + return creaDiv; +} \ No newline at end of file