Build a Cargo Manifest Validator - Build a Cargo Manifest Validator

Tell us what’s happening:

I’m having issues with test 15, its not very descriptive. I dont really know what it’s looking for…

Your code so far

const normalizeUnits = (manifest) => {
  let norm = {...manifest}
  if (norm.unit == "lb") {
    norm.weight = norm.weight * 0.45
    norm.unit = "kg"
  }
  return norm
}


const validateManifest = (manifest) => {
  const output = {}
  
  if (typeof manifest !== "object" || manifest === null) {
    return {
      containerId: "Invalid",
      destination: "Invalid",
      weight: "Invalid",
      unit: "Invalid",
      hazmat: "Invalid"
    }
  }
  
  if (!manifest.containerId && manifest.containerId !== null && manifest.containerId !== 0) {
    output.containerId = "Missing"
  } else if (!Number.isInteger(manifest.containerId) 
    || manifest.containerId <= 0) {
      output.containerId = "Invalid"
  }
  if (!manifest.destination && manifest.destination !== null) {
    output.destination = "Missing"
  } else if (typeof manifest?.destination !== 'string' 
    || manifest?.destination?.trim() == "") {
    output.destination = "Invalid"
  }
  if (!Number.isNaN(manifest.weight) && !manifest.weight && manifest.weight !== null) {
    output.weight = "Missing"
  } else if (!Number.isInteger(manifest.weight) 
    || Number.isNaN(manifest.weight) || manifest.weight < 0) {
      output.weight = "Invalid"
  }
  if (!manifest.unit && manifest.unit !== null) {
    output.unit = "Missing"
  } else if (manifest?.unit?.trim() !== "kg"
    && manifest?.unit?.trim() !== "lb") {
      output.unit = "Invalid"
    }
  if (manifest.hazmat == undefined && manifest.hazmat !== null) {
    output.hazmat = "Missing"
  } else if (manifest.hazmat !== true && manifest.hazmat !== false) {
    output.hazmat = "Invalid"
  }
  return output
}

console.log(validateManifest({containerId:NaN, destination:"             ",weight: -1, unit: "pound", hazmat: 0 }))

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:150.0) Gecko/20100101 Firefox/150.0

Challenge Information:

Build a Cargo Manifest Validator - Build a Cargo Manifest Validator

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-cargo-manifest-validator/69a56b5069ca99f7317e6e19.md at main · freeCodeCamp/freeCodeCamp · GitHub

please check again the user stories, make sure you are implementing all the validation correctly

one thing you should keep in mind:

console.log(validateManifest({containerId:NaN, destination:"             ",weight: -1, unit: "pound", hazmat: 0 }))

you are printing this, and containerId is there, but then in the output object there is containerId: 'Missing', which is not true