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()
}
}),
);
}
The fact is it an
ifis irrelevant. It is code that appears after areturnstatement.When running the function, the JS engine will always return from the function before reaching the
if. Since it can never reach theif, theifis unreachable.