From 16280537034cde61e8803f2eedd300a78b821cbc Mon Sep 17 00:00:00 2001 From: Facundo Saucedo <43495919@terciariourquiza.edu.ar> Date: Thu, 14 May 2026 14:47:54 -0300 Subject: [PATCH] feat: add buildList function to create a list from an array of items --- ejercicios-clase-8.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ejercicios-clase-8.js b/ejercicios-clase-8.js index 1f3717f..e191e6f 100644 --- a/ejercicios-clase-8.js +++ b/ejercicios-clase-8.js @@ -75,4 +75,26 @@ const cleanList = (id) => { const changeImage = () => { const image = document.querySelector('img'); image.src = "foto2.jpg"; - image.alt = 'Locro';} \ No newline at end of file + image.alt = 'Locro';} + +// Ejercicio 8 + +const buildList = (arr) => { + const div = document.createElement('div'); + div.classList.add('grupo-comidas'); + + const h2 = document.createElement('h2'); + h2.textContent = arr[0]; + div.appendChild(h2); + + const ul = document.createElement('ul'); + + for (let i = 1; i < arr.length; i++) { + const li = document.createElement('li'); + li.textContent = arr[i]; + ul.appendChild(li); + } + + div.appendChild(ul); + return div; +}; \ No newline at end of file