Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!