ejercicio 4

This commit is contained in:
2026-05-25 15:11:20 -03:00
parent 18c88a99b0
commit 0f5e6cd31d

View File

@@ -1,10 +1,15 @@
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios. // Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
// ejercicio 1
console.log("El archivo esta vinculado correctamente.") console.log("El archivo esta vinculado correctamente.")
const parrafo = document.querySelector("h1"); const parrafo = document.querySelector("h1");
console.log(parrafo.textContent); console.log(parrafo.textContent);
parrafo.textContent = "Hola a todos!"; parrafo.textContent = "Hola a todos!";
/* ejercicio 2 */
function agregarLista() { function agregarLista() {
const items = document.querySelectorAll(".lista-comidas"); const items = document.querySelectorAll(".lista-comidas");
for (const item of items) { for (const item of items) {
@@ -12,6 +17,8 @@ function agregarLista() {
} }
} }
/* ejercicio 3 */
const lista = document.querySelector("ul"); const lista = document.querySelector("ul");
function agregarItem(){ function agregarItem(){
@@ -20,3 +27,16 @@ const lista = document.querySelector("ul");
nuevoItem.textContent = itemAgregado; nuevoItem.textContent = itemAgregado;
lista.appendChild(nuevoItem); lista.appendChild(nuevoItem);
} }
//ejercicio 4
const contenedor = document.getElementById("parrafos");
if(contenedor){
const oracion = contenedor.querySelectorAll("p");
const parrafosImportantes = Array.from(oracion).filter(palabra => palabra.textContent.toLowerCase().includes("importante"));
parrafosImportantes.forEach(parrafo => {
parrafo.classList.add("destacado");
});
}