Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
Why is this function not reading one of my parameters?

I have this function in JS that should return 'not sold'/'sold to {name}'/'unknown ticket id' depending on the value/existence of the "ticketId" key in the "tickets" object, but it just returns 'unknown ticket id' for any 'ticketId' value regardless of whether it is actually null or has a value assigned to it in the 'tickets' object.

  export function ticketStatus(tickets, ticketId) {
  if (tickets["ticketId"] === null) {
    return 'not sold';
  } else if (tickets["ticketId"] === undefined) {
    return 'unknown ticket id';
  } else {
    return ('sold to ' + tickets["ticketId"]);
  }
}

VSCode says that the "ticketId" parameter is declared but never read in the function. I'm guessing that's why the function keeps returning the undefined option. In that case, why is 'ticketId' not being read as it should?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

"ticketId" is a string, not the variable as you intended.

You probably meant tickets[ticketId]:

export function ticketStatus(tickets, ticketId) {
  if (tickets[ticketId] === null) {
    return "not sold";
  } else if (tickets[ticketId] === undefined) {
    return "unknown ticket id";
  } else {
    return "sold to " + tickets[ticketId];
  }
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda