Orses• 210
@orses
Posted
¡Hola, Estanislao (@EstanisEVL)!
Enhorabuena por tu reto.
Te propongo un par de sugerencias sobre la parte de JS:
- Cuando no uses
type="module"
en tu etiqueta script de html podrías usar las funciones IIFE que te permiten encapsular tu código, aislarlo del resto, evitar conflictos con librerías de terceros, evitar que otros sobrescriban tus variables y objetos, y mantener limpio el objeto globalwindows
. Es muy fácil, introduce todo tu código entre estas dos líneas siguientes
(() => {
// tu código aquí
})();
Puedes ver un ejemplo en mi código link
Si haces así, cuando vayas a la consola verás que no se puede acceder directamente a tus funciones.
- La segunda es una recomendación de estilo, pero eso es muy personal, por tanto tómalo como eso, una recomendación. Normalmente se declaran arriba las variables globales, luego las funciones y finalmente los eventListener();
Espero sea de tu interés y ayuda. ¡Saludos!
Marked as helpful
1