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