ejercicio 1: saludo personalizado

This commit is contained in:
2026-05-28 13:04:44 -03:00
parent 610d2530dd
commit 3f3d33484c
2 changed files with 20 additions and 2 deletions

View File

@@ -1 +1,13 @@
// Agregar aquí el código javascript
const nombreInput = document.getElementById('nombre');
const saludarBtn = document.getElementById('saludar');
const mensajeP = document.getElementById('mensaje');
saludarBtn.addEventListener('click', () => {
const nombre = nombreInput.value.trim();
if (nombre === '') {
mensajeP.textContent = 'Por favor, ingresá tu nombre.';
} else {
mensajeP.textContent = `Hola, ${nombre}!`;
}
});