From a754fa5f7188e24ccd870f5faf07d7807177600e Mon Sep 17 00:00:00 2001 From: Lilian Garcia Date: Tue, 3 Dec 2024 17:35:47 -0800 Subject: [PATCH 1/2] Finalice RFC --- practicas/rfc/rfcLilian/rfc-LilianGarcia.html | 127 ++++++++++++++++++ practicas/rfc/rfcLilian/rfcLilianGarcia.js | 30 +++++ 2 files changed, 157 insertions(+) create mode 100644 practicas/rfc/rfcLilian/rfc-LilianGarcia.html create mode 100644 practicas/rfc/rfcLilian/rfcLilianGarcia.js diff --git a/practicas/rfc/rfcLilian/rfc-LilianGarcia.html b/practicas/rfc/rfcLilian/rfc-LilianGarcia.html new file mode 100644 index 0000000..938c38e --- /dev/null +++ b/practicas/rfc/rfcLilian/rfc-LilianGarcia.html @@ -0,0 +1,127 @@ + + + + + + + Generador de RFC + + + + +

Generador de RFC

+
+ + + + + + + + + + + + + + + + + + + +
+ +

RFC Generado:

+

+ + + + + diff --git a/practicas/rfc/rfcLilian/rfcLilianGarcia.js b/practicas/rfc/rfcLilian/rfcLilianGarcia.js new file mode 100644 index 0000000..fbe6d6d --- /dev/null +++ b/practicas/rfc/rfcLilian/rfcLilianGarcia.js @@ -0,0 +1,30 @@ +function generarRFC() { + // Obtener valores del formulario + const nombre = document.getElementById("nombre").value.trim().toUpperCase(); + const apellidoPaterno = document.getElementById("apellidoPaterno").value.trim().toUpperCase(); + const apellidoMaterno = document.getElementById("apellidoMaterno").value.trim().toUpperCase(); + const diaNacimiento = document.getElementById("diaNacimiento").value.padStart(2, '0'); + const mesNacimiento = document.getElementById("mesNacimiento").value.padStart(2, '0'); + const anoNacimiento = document.getElementById("anoNacimiento").value.padStart(2, '0'); + + // Validación de vocal en el apellido paterno + const vocales = ['A', 'E', 'I', 'O', 'U']; + let segundaLetra = ''; + for (let letra of apellidoPaterno.slice(1)) { + if (vocales.includes(letra)) { + segundaLetra = letra; + break; + } + } + if (!segundaLetra) { + alert("El apellido paterno debe contener al menos una vocal después de la primera letra."); + return; + } + + // Construir las partes del RFC + const rfc = `${apellidoPaterno[0]}${segundaLetra}${apellidoMaterno[0]}${nombre[0]}` + + `-${anoNacimiento}${mesNacimiento}${diaNacimiento}-XXX`; + + // Mostrar el resultado en la página + document.getElementById("resultadoRFC").innerText = rfc; +} From 6d29a8ca8247ca164c3944bba0374cb5db5050c9 Mon Sep 17 00:00:00 2001 From: Lilian Garcia Date: Tue, 3 Dec 2024 18:35:29 -0800 Subject: [PATCH 2/2] =?UTF-8?q?Temin=C3=A9TareapromesasPokemonOfflineLilia?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PromesasPokemonLilian.js | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 practicas/promesaspokemonoffline/PromesasPokemonLilian.js diff --git a/practicas/promesaspokemonoffline/PromesasPokemonLilian.js b/practicas/promesaspokemonoffline/PromesasPokemonLilian.js new file mode 100644 index 0000000..3d812e9 --- /dev/null +++ b/practicas/promesaspokemonoffline/PromesasPokemonLilian.js @@ -0,0 +1,67 @@ +const obtenerPokemonPromesas = (nombrePokemon) => { + return new Promise((resolve, reject) => { + // Simular una solicitud asincrona para obtener datos del pokemón + const pokemonDatabase = { + "pikachu": { + "nombre": "Pikachu", + "tipo": "Electrico", + "habilidad": "Electricidad" + }, + "bulbasaur": { + "nombre": "Bulbasaur", + "tipo": "Planta", + "habilidad": "Latigo Cepa" + }, + "charmander": { + "nombre": "Charmander", + "tipo": "Fuego", + "habilidad": "Lanza Llamas" + }, + + "mew":{ + "nombre": "Mew", + "tipo": "Psíquico", + "habilidad": "Teletransporte" + }, + + "lucario":{ + "nombre": "Lucario", + "tipo": "Lucha", + "habilidad": "Fuerza de la Llama" + }, + + } + + // Comprobar si el pokemon recibido existe en la base de datos. + const pokemonEncontrado = pokemonDatabase[nombrePokemon.toLowerCase()]; + + if (pokemonEncontrado) { + resolve(pokemonEncontrado); + } else { + reject('No se encontro el pokemon con nombre ' + nombrePokemon); + } + }); + +}; + + obtenerPokemonPromesas('mew') + .then((pokemon) => { + console.log('Si lo encontre'); + }) + .catch((error) => { + console.log('error ', error); + }) + .finally(() => { + console.log('Se cierra la busqueda'); + }); + + obtenerPokemonPromesas('lucario') + .then((pokemon) => { + console.log('Si lo encontre'); + }) + .catch((error) => { + console.log('error ', error); + }) + .finally(() => { + console.log('Se cierra la busqueda'); + }); \ No newline at end of file