Comparto mi código del 1ra práctica desafió.
alert("¡Bienvenida y bienvenido a nuestro sitio web!"); // Display an alert with the welcome message.
let nombre = "Lua"; // Declare a variable named 'nombre' and assign it the value "Lua".
let edad = 25;
let numeroDeVentas = 50; // Set a variable 'numeroDeVentas' and assign it the value 50.
let saldoDisponible = 1000; // Set a variable 'saldoDisponible' and assign it the value 1000.
alert("¡Error! Completa todos los campos"); // Display an alert with the error message
let mensajeDeError = "¡Error! Completa todos los campos"; // Declare a variable named 'mensajeDeError' and assign it the error message value.
alert(mensajeDeError); //Display an alert with the value of the 'mensajeDeError' variable.
let usuario = prompt("Ingresa tu usuario"); // Use a prompt to ask for the user's name and store it in the 'nombre' variable.
let edadUsuario = prompt("Ingresa tu edad"); // Ask the user to enter their age using a prompt and store it in the 'edad' variable.
if (edadUsuario >= 18) { // Check if the age is 18 or older.
alert("¡Puedes obtener tu licencia de conducir!"); // Display an alert if the user is 18 or older.
}
Anteriormente, mi código en JavaScript presentaba problemas. Me di cuenta de que el error ocurría porque usaba el mismo nombre para una variable más de una vez. Sabemos que, en este ámbito, no es posible declarar una variable con el mismo nombre dos veces. Como mencioné, logré identificar mi error y estoy segura de que otros compañeros que enfrenten el mismo problema podrán solucionarlo.