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

199
Views
Why i get error "unreachable code" when i try to put an if in my function?

When i insert "if (descriptions >= 0.4){zien()} then it gets red underlined with error "unreachable code". Why is that??

function loadLabeledImages() {
  const labels = ['Simon', 'Thomas'];
  return Promise.all(
    labels.map(async (label) => {
      const img = await faceapi.fetchImage(`./images/${label}.jpg`);
      const detections = await faceapi
      .detectSingleFace(img)
      .withFaceLandmarks()
      .withFaceDescriptor();
      const descriptions = [detections.descriptor];
      return new faceapi.LabeledFaceDescriptors(label, descriptions);

      if (descriptions >= 0.4){
        zien()
      }
    }),

  );

}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The fact is it an if is irrelevant. It is code that appears after a return statement.

When running the function, the JS engine will always return from the function before reaching the if. Since it can never reach the if, the if is unreachable.

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!