From d7c0464b87036610c61c33bccab604cb31b278ef Mon Sep 17 00:00:00 2001 From: maximo hidalgo <47135001@gmail.com> Date: Thu, 21 May 2026 17:57:51 -0300 Subject: [PATCH] agrega funcion contruirLista --- ejercicios-clase-8.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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