Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/01-var-let-const/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@
// Declara una constante llamada PI con el valor 3.14159
// y retórnala.
function obtenerPI() {
// Tu código aquí
const PI = 3.14159;
return PI;
}

// --- Reto 2: Reasignación con let ---
// Declara una variable con let llamada "contador" e inicialízala en 0.
// Luego reasígnala a 5.
// Retorna el valor final de contador.
function obtenerContador() {
// Tu código aquí
let contador = 0;
contador = 5;
return contador;
}

// --- Reto 3: Constante de texto ---
// Declara una constante llamada NOMBRE_CURSO con el valor
// "Fundamentos de JavaScript" y retórnala.
function obtenerNombreCurso() {
// Tu código aquí
const NOMBRE_CURSO = "Fundamentos de JavaScript";
return NOMBRE_CURSO;
}

// --- Reto 4: Reasignación de strings ---
Expand All @@ -34,7 +37,11 @@ function obtenerNombreCurso() {
// { inicial: "hola", final: "adiós" }
// Pista: guarda el valor inicial antes de reasignar.
function reasignarMensaje() {
// Tu código aquí
let mensaje = 'Hola';
const inicial = mensaje;
mensaje = 'Adios';
const final = mensaje;
return {inicial, final};
}

// --- Reto 5: Cálculo con const y let ---
Expand All @@ -44,7 +51,11 @@ function reasignarMensaje() {
// Calcula el total como: precioBase - descuento.
// Retorna un objeto: { precioBase, descuento, total }
function calcularTotal() {
// Tu código aquí
const precioBase = 100;
let vardescuento = 10;
vardescuento = 25;
const total = precioBase - vardescuento
return {precioBase, vardescuento, total}
}

// --- Reto 6: Identificar tipos de dato ---
Expand All @@ -56,9 +67,9 @@ function identificarTipos() {
const activo = true;

return {
tipoEdad: undefined, // Reemplaza undefined por typeof de edad
tipoNombre: undefined, // Reemplaza undefined por typeof de nombre
tipoActivo: undefined, // Reemplaza undefined por typeof de activo
tipoEdad: typeof edad,
tipoNombre: typeof nombre,
tipoActivo: typeof Activo
};
}

Expand All @@ -69,7 +80,10 @@ function identificarTipos() {
// { antes: undefined, despues: "Oscar" }
// Pista: declara "nombre" con var después del primer acceso.
function demostrarHoisting() {
// Tu código aquí
var antes = "nombre";
var nombre = "oscar";
var despues = "nombre";
return {antes, despues }
// Paso 1: guarda el valor de "nombre" en una variable "antes"
// Paso 2: declara var nombre = "Oscar"
// Paso 3: guarda el valor de "nombre" en una variable "despues"
Expand Down