1 Commits

Author SHA1 Message Date
Juanse Marquez
52c3871b2b Solución ejercicio 9 2026-06-01 18:48:46 -03:00
23 changed files with 311 additions and 545 deletions

View File

@@ -1,13 +1 @@
const nombreInput = document.getElementById('nombre'); // Agregar aquí el código javascript
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}!`;
}
});

View File

@@ -2,19 +2,13 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>Ejercicio 1</title> <title>Ejercicio 1</title>
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 1</h1> <h1>Ejercicio 1</h1>
<label for="nombre">Ingresa tu nombre:</label>
<input id="nombre" type="text" placeholder="Tu nombre">
<button id="saludar">Saludar</button>
<p id="mensaje"></p>
<script src="ejercicio1.js"></script> <script src="ejercicio1.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,16 +1 @@
const tareaInput = document.getElementById('tarea'); // Agregar aquí el código javascript
const agregarBtn = document.getElementById('agregar');
const listaTareas = document.getElementById('lista-tareas');
agregarBtn.addEventListener('click', () => {
const tarea = tareaInput.value.trim();
if (tarea === '') {
return;
}
const li = document.createElement('li');
li.textContent = tarea;
listaTareas.appendChild(li);
tareaInput.value = '';
});

View File

@@ -2,19 +2,13 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>Ejercicio 2</title> <title>Ejercicio 2</title>
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 2</h1> <h1>Ejercicio 2</h1>
<label for="tarea">Nueva tarea:</label>
<input id="tarea" type="text" placeholder="Escribí una tarea">
<button id="agregar">Agregar</button>
<ul id="lista-tareas"></ul>
<script src="ejercicio2.js"></script> <script src="ejercicio2.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,11 +1 @@
const listaItems = document.getElementById('lista-items'); // Agregar aquí el código javascript
listaItems.addEventListener('click', (event) => {
const item = event.target;
if (item.tagName.toLowerCase() !== 'li') {
return;
}
item.classList.toggle('seleccionado');
});

View File

@@ -1,7 +1,2 @@
/* Agregar el código CSS necesario para el ejercicio */ /* Agregar el código CSS necesario para el ejercicio */
.seleccionado {
background-color: yellow;
font-weight: bold;
}

View File

@@ -2,22 +2,13 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>Ejercicio 3</title> <title>Ejercicio 3</title>
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 3</h1> <h1>Ejercicio 3</h1>
<ul id="lista-items">
<li>Zapatos nuevos</li>
<li>Leer un capítulo</li>
<li>Comprar frutas</li>
<li>Enviar el informe</li>
<li>Escuchar música</li>
<li>Practicar JavaScript</li>
</ul>
<script src="ejercicio3.js"></script> <script src="ejercicio3.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,29 +1 @@
const restarBtn = document.getElementById('restar'); // Agregar aquí el código javascript
const sumarBtn = document.getElementById('sumar');
const valorSpan = document.getElementById('valor');
let contador = 0;
const LIMITE_MIN = 0;
const LIMITE_MAX = 10;
function actualizarEstado() {
valorSpan.textContent = contador;
restarBtn.disabled = contador <= LIMITE_MIN;
sumarBtn.disabled = contador >= LIMITE_MAX;
}
restarBtn.addEventListener('click', () => {
if (contador > LIMITE_MIN) {
contador -= 1;
actualizarEstado();
}
});
sumarBtn.addEventListener('click', () => {
if (contador < LIMITE_MAX) {
contador += 1;
actualizarEstado();
}
});
actualizarEstado();

View File

@@ -2,17 +2,13 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>Ejercicio 4</title> <title>Ejercicio 4</title>
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 4</h1> <h1>Ejercicio 4</h1>
<button id="restar">Restar</button>
<button id="sumar">Sumar</button>
<p>Contador: <span id="valor">0</span></p>
<script src="ejercicio4.js"></script> <script src="ejercicio4.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,43 +1 @@
const paises = [ // Agregar aquí el código javascript
'Argentina',
'Brasil',
'Canadá',
'Dinamarca',
'España',
'Filipinas',
'Grecia',
'Hungría',
'India',
'Japón',
'México',
'Noruega'
];
const filtroInput = document.getElementById('filtro');
const listaPaises = document.getElementById('lista-paises');
function renderizarLista(items) {
listaPaises.innerHTML = '';
items.forEach((pais) => {
const li = document.createElement('li');
li.textContent = pais;
listaPaises.appendChild(li);
});
}
function filtrarPaises(texto) {
const valor = texto.trim().toLowerCase();
if (valor === '') {
return paises;
}
return paises.filter((pais) => pais.toLowerCase().includes(valor));
}
filtroInput.addEventListener('input', (event) => {
const paisesFiltrados = filtrarPaises(event.target.value);
renderizarLista(paisesFiltrados);
});
renderizarLista(paises);

View File

@@ -1,28 +1,2 @@
/* Agregar el código CSS necesario para el ejercicio */ /* Agregar el código CSS necesario para el ejercicio */
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label,
input {
display: block;
margin-bottom: 10px;
}
input {
padding: 8px;
max-width: 300px;
}
ul {
list-style: disc inside;
padding-left: 0;
max-width: 320px;
}
li {
margin-bottom: 5px;
}

View File

@@ -2,18 +2,13 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>Ejercicio 5</title> <title>Ejercicio 5</title>
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 5</h1> <h1>Ejercicio 5</h1>
<label for="filtro">Buscar país:</label>
<input id="filtro" type="text" placeholder="Escribí para filtrar">
<ul id="lista-paises"></ul>
<script src="ejercicio5.js"></script> <script src="ejercicio5.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,50 +1 @@
const empleados = [ // Agregar aquí el código javascript
{ nombre: 'Ana', sector: 'Desarrollo', sueldo: 150000 },
{ nombre: 'Luis', sector: 'Diseño', sueldo: 120000 },
{ nombre: 'Marta', sector: 'Desarrollo', sueldo: 160000 },
{ nombre: 'Carlos', sector: 'RRHH', sueldo: 110000 },
{ nombre: 'Julia', sector: 'Diseño', sueldo: 130000 }
];
const tablaEmpleados = document.getElementById('tabla-empleados');
const cuerpoTabla = tablaEmpleados.querySelector('tbody');
const pieTabla = tablaEmpleados.querySelector('tfoot');
function formatearSueldo(valor) {
return `$${valor.toLocaleString('es-AR')}`;
}
function renderizarTabla() {
cuerpoTabla.innerHTML = '';
let totalSueldo = 0;
empleados.forEach((empleado) => {
const fila = document.createElement('tr');
const celdaNombre = document.createElement('td');
celdaNombre.textContent = empleado.nombre;
const celdaSector = document.createElement('td');
celdaSector.textContent = empleado.sector;
const celdaSueldo = document.createElement('td');
celdaSueldo.textContent = formatearSueldo(empleado.sueldo);
fila.appendChild(celdaNombre);
fila.appendChild(celdaSector);
fila.appendChild(celdaSueldo);
cuerpoTabla.appendChild(fila);
totalSueldo += empleado.sueldo;
});
const promedio = Math.round(totalSueldo / empleados.length);
pieTabla.innerHTML = `
<tr>
<td colspan="2"><strong>Sueldo promedio</strong></td>
<td><strong>${formatearSueldo(promedio)}</strong></td>
</tr>
`;
}
renderizarTabla();

View File

@@ -1,28 +1,2 @@
/* Agregar el código CSS necesario para el ejercicio */ /* Agregar el código CSS necesario para el ejercicio */
body {
font-family: Arial, sans-serif;
margin: 20px;
}
table {
border-collapse: collapse;
width: 100%;
max-width: 600px;
}
th,
td {
border: 1px solid #ccc;
padding: 8px 12px;
text-align: left;
}
th {
background-color: #f4f4f4;
}
tfoot td {
background-color: #fafafa;
}

View File

@@ -2,25 +2,13 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>Ejercicio 6</title> <title>Ejercicio 6</title>
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 6</h1> <h1>Ejercicio 6</h1>
<table id="tabla-empleados">
<thead>
<tr>
<th>Nombre</th>
<th>Sector</th>
<th>Sueldo</th>
</tr>
</thead>
<tbody></tbody>
<tfoot></tfoot>
</table>
<script src="ejercicio6.js"></script> <script src="ejercicio6.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,61 +1 @@
const formulario = document.getElementById('formulario'); // Agregar aquí el código javascript
const nombreInput = document.getElementById('nombre');
const edadInput = document.getElementById('edad');
const contrasenaInput = document.getElementById('contrasena');
const errorNombre = document.getElementById('error-nombre');
const errorEdad = document.getElementById('error-edad');
const errorContrasena = document.getElementById('error-contrasena');
const mensajeExito = document.getElementById('mensaje-exito');
function limpiarErrores() {
errorNombre.textContent = '';
errorEdad.textContent = '';
errorContrasena.textContent = '';
mensajeExito.textContent = '';
}
function validarFormulario() {
limpiarErrores();
let esValido = true;
const nombre = nombreInput.value.trim();
const edad = edadInput.value.trim();
const contrasena = contrasenaInput.value;
if (nombre === '') {
errorNombre.textContent = 'El nombre no puede quedar vacío.';
esValido = false;
}
if (edad === '') {
errorEdad.textContent = 'La edad no puede quedar vacía.';
esValido = false;
} else {
const edadNumero = Number(edad);
if (!Number.isInteger(edadNumero) || edadNumero < 0 || edadNumero > 100) {
errorEdad.textContent = 'La edad debe ser un número entero entre 0 y 100.';
esValido = false;
}
}
if (contrasena === '') {
errorContrasena.textContent = 'La contraseña no puede quedar vacía.';
esValido = false;
} else if (contrasena.length < 8) {
errorContrasena.textContent = 'La contraseña debe tener al menos 8 caracteres.';
esValido = false;
}
return esValido;
}
formulario.addEventListener('submit', (event) => {
event.preventDefault();
if (validarFormulario()) {
mensajeExito.textContent = 'Formulario enviado correctamente.';
} else {
mensajeExito.textContent = '';
}
});

View File

@@ -1,42 +1,2 @@
/* Agregar el código CSS necesario para el ejercicio */ /* Agregar el código CSS necesario para el ejercicio */
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.campo {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 4px;
}
input {
display: block;
width: 100%;
max-width: 320px;
padding: 8px;
box-sizing: border-box;
}
button {
padding: 10px 16px;
cursor: pointer;
}
.error {
display: block;
margin-top: 4px;
color: #c0392b;
font-size: 0.95rem;
}
.exito {
margin-top: 16px;
color: #2d7a2d;
font-weight: bold;
}

View File

@@ -2,37 +2,13 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>Ejercicio 7</title> <title>Ejercicio 7</title>
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 7</h1> <h1>Ejercicio 7</h1>
<form id="formulario">
<div class="campo">
<label for="nombre">Nombre:</label>
<input id="nombre" name="nombre" type="text">
<span class="error" id="error-nombre"></span>
</div>
<div class="campo">
<label for="edad">Edad:</label>
<input id="edad" name="edad" type="number" min="0" max="100">
<span class="error" id="error-edad"></span>
</div>
<div class="campo">
<label for="contrasena">Contraseña:</label>
<input id="contrasena" name="contrasena" type="password">
<span class="error" id="error-contrasena"></span>
</div>
<button type="submit">Enviar</button>
</form>
<p id="mensaje-exito" class="exito" aria-live="polite"></p>
<script src="ejercicio7.js"></script> <script src="ejercicio7.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,71 +1 @@
const productos = [ // Agregar aquí el código javascript
{ nombre: "Teclado", precio: 8500 },
{ nombre: "Mouse", precio: 4200 },
{ nombre: "Monitor", precio: 62000 },
{ nombre: "Auriculares", precio: 11000 },
{ nombre: "Webcam", precio: 15500 }
];
const contenedorProductos = document.querySelector("#productos");
const carritoLista = document.querySelector("#carrito");
const totalTexto = document.querySelector("#total");
const carrito = [];
function mostrarProductos() {
for (const producto of productos) {
const div = document.createElement("div");
div.innerHTML = `
<span>${producto.nombre} - $${producto.precio}</span>
<button>Agregar al carrito</button>
`;
const boton = div.querySelector("button");
boton.addEventListener("click", () => {
agregarAlCarrito(producto);
});
contenedorProductos.appendChild(div);
}
}
function agregarAlCarrito(producto) {
const existente = carrito.find(
item => item.nombre === producto.nombre
);
if (existente) {
existente.cantidad++;
} else {
carrito.push({
nombre: producto.nombre,
precio: producto.precio,
cantidad: 1
});
}
actualizarCarrito();
}
function actualizarCarrito() {
carritoLista.innerHTML = "";
let total = 0;
for (const item of carrito) {
const li = document.createElement("li");
li.textContent =
`${item.nombre} x${item.cantidad} - $${item.precio * item.cantidad}`;
carritoLista.appendChild(li);
total += item.precio * item.cantidad;
}
totalTexto.textContent = `Total: $${total}`;
}
mostrarProductos();

View File

@@ -8,15 +8,7 @@
</head> </head>
<body> <body>
<h1>Ejercicio 8</h1> <h1>Ejercicio 8</h1>
<h1>Productos</h1>
<div id="productos"></div>
<h2>Carrito</h2>
<ul id="carrito"></ul>
<p id="total">Total: $0</p>
<script src="ejercicio8.js"></script> <script src="ejercicio8.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,99 +1,133 @@
const preguntas = [ const preguntas = [
{ {
pregunta: "¿Capital de Francia?", pregunta: "¿Cuál es la diferencia entre let y const?",
opciones: ["Madrid", "París", "Roma", "Berlín"], opciones: [
"No hay diferencia, son equivalentes",
"let permite reasignar el valor, const no",
"Depende del tipo de datos",
"let solo funciona dentro de funciones"
],
correcta: 1 correcta: 1
}, },
{ {
pregunta: "¿Capital de Argentina?", pregunta: "¿Qué retorna querySelector si no encuentra ningún elemento?",
opciones: ["Rosario", "Córdoba", "Buenos Aires", "Mendoza"], opciones: ["undefined", "false", "null", "0"],
correcta: 2 correcta: 2
}, },
{ {
pregunta: "¿Capital de Brasil?", pregunta: "¿Qué hace el método filter?",
opciones: ["Brasilia", "Río", "San Pablo", "Lima"], opciones: [
correcta: 0 "Modifica los elementos del array original",
"Retorna el primer elemento que cumple la condición",
"Retorna un nuevo array con los elementos que cumplen la condición",
"Elimina elementos duplicados del array"
],
correcta: 2
}, },
{ {
pregunta: "¿Capital de Italia?", pregunta: "¿Cuál es el operador de igualdad estricta en JavaScript?",
opciones: ["Roma", "Milán", "Nápoles", "Venecia"], opciones: ["=", "==", "===", "!="],
correcta: 0 correcta: 2
}, },
{ {
pregunta: "¿Capital de Alemania?", pregunta: "¿Para qué sirve event.preventDefault()?",
opciones: ["Hamburgo", "Berlín", "Múnich", "Frankfurt"], opciones: [
"Detiene la propagación del evento hacia elementos padre",
"Evita el comportamiento por defecto del navegador",
"Elimina el event listener del elemento",
"Pausa la ejecución del código hasta que el evento termine"
],
correcta: 1 correcta: 1
} }
]; ];
const quiz = document.querySelector("#quiz"); let indiceActual = 0;
const botonSiguiente = document.querySelector("#siguiente");
let indice = 0;
let puntaje = 0; let puntaje = 0;
function mostrarPregunta() { const pantalla = document.querySelector("#pantalla-quiz");
quiz.innerHTML = ""; const resultadoEl = document.querySelector("#resultado");
const preguntaEl = document.querySelector("#pregunta");
const opcionesEl = document.querySelector("#opciones");
const feedbackEl = document.querySelector("#feedback");
const btnSiguiente = document.querySelector("#siguiente");
const progresoEl = document.querySelector("#progreso");
const progressFill = document.querySelector("#progress-fill");
const puntajeNumEl = document.querySelector("#puntaje-num");
const resultadoMsg = document.querySelector("#resultado-msg");
const btnReiniciar = document.querySelector("#reiniciar");
const pregunta = preguntas[indice]; function mensajeFinal(p, total) {
if (p === total) return "¡Perfecto! Todo bien.";
const h2 = document.createElement("h2"); if (p >= total * 0.8) return "¡Muy bien!";
h2.textContent = pregunta.pregunta; if (p >= total * 0.6) return "Bien, pero hay margen para mejorar.";
return "Vale la pena repasar los temas.";
quiz.appendChild(h2);
pregunta.opciones.forEach((opcion, i) => {
const boton = document.createElement("button");
boton.textContent = opcion;
boton.addEventListener("click", () => {
verificarRespuesta(i);
});
quiz.appendChild(boton);
});
} }
function verificarRespuesta(opcionElegida) { function mostrarPregunta() {
const correcta = preguntas[indice].correcta; const actual = preguntas[indiceActual];
if (opcionElegida === correcta) { // Actualizamos el encabezado y la barra de progreso.
puntaje++; progresoEl.textContent = `${indiceActual + 1} / ${preguntas.length}`;
alert("Correcto"); progressFill.style.width = `${(indiceActual / preguntas.length) * 100}%`;
} else {
alert("Incorrecto"); preguntaEl.textContent = actual.pregunta;
opcionesEl.innerHTML = "";
feedbackEl.textContent = "";
btnSiguiente.style.display = "none";
for (let i = 0; i < actual.opciones.length; i++) {
const boton = document.createElement("button");
boton.className = "opcion";
boton.textContent = actual.opciones[i];
boton.addEventListener("click", () => responder(i));
opcionesEl.appendChild(boton);
}
}
function responder(indiceRespuesta) {
const actual = preguntas[indiceActual];
const botones = opcionesEl.querySelectorAll(".opcion");
// Deshabilitamos todos los botones para que no se pueda responder dos veces.
for (const boton of botones) {
boton.disabled = true;
} }
botonSiguiente.style.display = "block"; if (indiceRespuesta === actual.correcta) {
botones[indiceRespuesta].classList.add("correcta");
feedbackEl.textContent = "¡Correcto!";
puntaje++;
} else {
botones[indiceRespuesta].classList.add("incorrecta");
botones[actual.correcta].classList.add("correcta");
feedbackEl.textContent = `Incorrecto. La correcta era: "${actual.opciones[actual.correcta]}"`;
}
btnSiguiente.style.display = "inline-block";
} }
botonSiguiente.addEventListener("click", () => { btnSiguiente.addEventListener("click", () => {
indice++; indiceActual++;
if (indice < preguntas.length) { if (indiceActual < preguntas.length) {
mostrarPregunta(); mostrarPregunta();
botonSiguiente.style.display = "none";
} else { } else {
mostrarResultado(); // Actualizamos la barra al 100% antes de mostrar el resultado.
progressFill.style.width = "100%";
pantalla.style.display = "none";
resultadoEl.style.display = "block";
puntajeNumEl.textContent = `${puntaje} / ${preguntas.length}`;
resultadoMsg.textContent = mensajeFinal(puntaje, preguntas.length);
} }
}); });
function mostrarResultado() { btnReiniciar.addEventListener("click", () => {
quiz.innerHTML = ` indiceActual = 0;
<h2>Puntaje: ${puntaje} de ${preguntas.length}</h2>
<button id="reiniciar">Reiniciar</button>
`;
botonSiguiente.style.display = "none";
document
.querySelector("#reiniciar")
.addEventListener("click", () => {
indice = 0;
puntaje = 0; puntaje = 0;
resultadoEl.style.display = "none";
pantalla.style.display = "block";
mostrarPregunta(); mostrarPregunta();
}); });
}
mostrarPregunta(); mostrarPregunta();

View File

@@ -1,2 +1,168 @@
/* Agregar el código CSS necesario para el ejercicio */ /* Hoja de estilo realizada con IA */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: system-ui, sans-serif;
background: #f5f4f0;
color: #1a1a1a;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
}
.card {
background: #fff;
border: 0.5px solid #ddd;
border-radius: 16px;
padding: 2rem;
width: 100%;
max-width: 520px;
}
/* ── Encabezado ── */
.quiz-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1.5rem;
}
.quiz-title {
font-size: 0.7rem;
font-weight: 500;
color: #888;
text-transform: uppercase;
letter-spacing: 0.06em;
}
.quiz-progress {
font-size: 0.75rem;
color: #aaa;
}
/* ── Barra de progreso ── */
.progress-bar {
height: 4px;
background: #eee;
border-radius: 2px;
margin-bottom: 2rem;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: #1a1a1a;
border-radius: 2px;
transition: width 0.3s ease;
}
/* ── Pregunta ── */
#pregunta {
font-size: 1.05rem;
font-weight: 500;
line-height: 1.5;
margin-bottom: 1.5rem;
min-height: 3rem;
}
/* ── Opciones ── */
#opciones {
display: flex;
flex-direction: column;
gap: 8px;
margin-bottom: 1.5rem;
}
.opcion {
width: 100%;
text-align: left;
padding: 12px 16px;
background: #f5f4f0;
border: 0.5px solid #ddd;
border-radius: 8px;
font-size: 0.875rem;
color: #1a1a1a;
cursor: pointer;
transition: background 0.15s, border-color 0.15s;
}
.opcion:hover:not(:disabled) {
background: #edecea;
border-color: #bbb;
}
.opcion:disabled { cursor: default; }
.opcion.correcta {
background: #eaf3de;
border-color: #639922;
color: #3b6d11;
}
.opcion.incorrecta {
background: #fcebeb;
border-color: #e24b4a;
color: #a32d2d;
}
/* ── Feedback ── */
#feedback {
font-size: 0.8rem;
min-height: 1.2rem;
color: #555;
margin-bottom: 1.25rem;
}
/* ── Botones de acción ── */
.btn {
padding: 10px 20px;
font-size: 0.875rem;
font-weight: 500;
border-radius: 8px;
border: 0.5px solid #ccc;
background: #1a1a1a;
color: #fff;
cursor: pointer;
transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-secondary {
background: transparent;
color: #1a1a1a;
}
/* ── Pantalla de resultado ── */
#resultado {
text-align: center;
padding: 1rem 0;
}
.resultado-score {
font-size: 3rem;
font-weight: 500;
line-height: 1;
margin-bottom: 0.5rem;
}
.resultado-label {
font-size: 0.875rem;
color: #888;
margin-bottom: 0.5rem;
}
.resultado-msg {
font-size: 1rem;
font-weight: 500;
margin-bottom: 2rem;
}

View File

@@ -7,14 +7,37 @@
<link rel="stylesheet" href="estilo.css"> <link rel="stylesheet" href="estilo.css">
</head> </head>
<body> <body>
<h1>Ejercicio 9</h1>
<h1>Quiz</h1>
<div id="quiz"></div> <div class="card">
<div id="pantalla-quiz">
<div class="quiz-header">
<span class="quiz-title">Ejercicio 9 - Quiz de JavaScript</span>
<span class="quiz-progress" id="progreso">1 / 5</span>
</div>
<div class="progress-bar">
<div class="progress-fill" id="progress-fill" style="width: 0%"></div>
</div>
<p id="pregunta"></p>
<div id="opciones"></div>
<p id="feedback"></p>
<button class="btn" id="siguiente" style="display:none">Siguiente →</button>
</div>
<div id="resultado" style="display:none">
<p class="resultado-score" id="puntaje-num"></p>
<p class="resultado-label">respuestas correctas</p>
<p class="resultado-msg" id="resultado-msg"></p>
<button class="btn btn-secondary" id="reiniciar">Reiniciar quiz</button>
</div>
</div>
<button id="siguiente" style="display:none">
Siguiente
</button>
<script src="ejercicio9.js"></script> <script src="ejercicio9.js"></script>
</body> </body>
</html> </html>