Build a Cargo Manifest Validator - Step 14

Hello, please I’d like to know why step 14 isn’t passing and all other steps pass, I’ve made lots of correction but it still wont pass

function validateManifest(manifest){
  let manifest2 = {};
   
  if (!Object.hasOwn(manifest, "containerId")){
    manifest2.containerId = "Missing"
    
  } else if (typeof manifest.containerId !== "number" ||manifest.containerId <= 0 || !Number.isInteger(manifest.containerId)) { manifest2.containerId = "Invalid"
   
  }; 
  
   if (!Object.hasOwn(manifest, "destination")){
    manifest2.destination = "Missing"
    
  } else if (typeof manifest.destination !== "string" || manifest.destination.trim().length == 0 ){  manifest2.destination = "Invalid"
   
  }; 

  
 if (!Object.hasOwn(manifest, "weight")){
    manifest2.weight = "Missing"
    
  } else if (typeof manifest.weight !== "number" || manifest.weight <= 0 || Number.isNaN(manifest.weight)){  manifest2.weight = "Invalid"
  
  };
 
  if (!Object.hasOwn(manifest, "unit")){
    manifest2.unit = "Missing"
  } else if (manifest.unit !== "kg" && manifest.unit !== "lb" || !["kg", "lb"].includes(manifest.unit.toLowerCase())){  manifest2.unit = "Invalid"
  
  };

   if (!Object.hasOwn(manifest, "hazmat")){
    manifest2.hazmat = "Missing"
  } else if (manifest.hazmat !=  true && manifest.hazmat != false){  manifest2.hazmat = "Invalid"
  
  };
   return manifest2
  
};

can you please post the link to the project and format your code?

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like