Build a Cargo Manifest Validator - Build a Cargo Manifest Validator

Tell us what’s happening:

the codes are not going through at all , please what are exactly missing??

Your code so far

function normalizedUnits(manifest) {
  const normalizedManifest = { ...manifest};
  if (normalizedmanifest.unit === "lb") {
    normalizedManifest.weight = normalizedManifest.weight * 0.45;
    normalizedManifest.unit = "Kg";
  }
  return normalizedManifest;
}
function validateManifest(manifest) {
 const errors = {};
 if (! manifest.hasOwnProperty("containerId")) {
   errors.containerId = "Missing";
 } else if (
   ! Number.isInteger(manifest.containerId) ||
  manifest.containerId < 1
 ) {
   errors.containerId = "Invalid";
 }
 if (! manifest.hasOwnProperty("destination")) {
   errors.destination = "Missing";
 } else if (
   typeof manifest.destination !== "string" ||
   manifest.destination.trim().length === 0
 ) {
   errors.destination = "Invalid";
 }
 if (! manifest.hasOwnProperty("unit")) {
   errors.unit = "Missing";
 } else if (
   manifest.unit !== "kg" &&
   manifest.unit !== "lb"
 ) {
   errors.unit = "Invalid";
 }
 if (! manifest.hasOWnProperty("weight")) {
   errors.weight = "Missing";
 } else if (
   typeof manifest.weight !== "number" ||
   Number.isNaN(manifest.weight) ||
   manifest.weight <= 0
 ) {
   errors.weight = "Invalid";
 }
 if (! manifest.hasOwnProperty("hazmat")) {
   errors.hamzat = "Missing";
 } else if (typeof manifest.hazmat !== "boolean") {
   errors.hazmat = "Invalid";
 }
 return errors;
}
function processManifest(manifest) {
  const errors = validateManifest(manifest);
const isValid = Object.keys(errors).length === 0;
if (isValid) {
  const normalized = normalizeUnits(manifest);   
  console.log(`Validation success: ${normalized.containerId}`);
  console.log(`Total weight: ${normalized.weight} kg`);
} else {
  console.log(`Validation error: ${manifest.containerId}`);
  console.log(errors);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0

Challenge Information:

Build a Cargo Manifest Validator - Build a Cargo Manifest Validator

Hi @alliluqmanadeniyi,

Here are some debugging steps you can follow. Focus on one test at a time:

  1. Are there any errors or messages in the console?
  2. What is the requirement of the failing test?
  3. Check the related User Story and ensure it’s followed precisely.
  4. What line of code implements this?
  5. What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)

If this does not help you solve the problem, please reply with answers to these questions.

Happy coding!