# Build a Cargo Manifest Validator - Build a Cargo Manifest Validator

**URL:** <https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801089>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [September 25, 2026, 7:21pm UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801089 "2026-09-25T19:21:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![niklasjansen02](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/niklasjansen02/32/422014_2.png) [@niklasjansen02](https://forum.freecodecamp.org/u/niklasjansen02)\
**Post date:** [September 25, 2026, 7:21pm UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801089/1 "2026-09-25T19:21:42Z")

</div>

### Tell us what’s happening:

My code seems to mostly be working, honestly the tests it says are wrong seem to be right when I log them. I dont really know whats wrong ☹

### Your code so far

```js
const container1 = {
  containerId: 1,
  destination: "Monterey, California, USA",
  weight: 831,
  unit: "lb",
  hazmat: false
}
const container0 = { destination: "Watsonville", hazmat: true }

function normalizeUnits (manifest){
  let normalizedManifest = {
    containerId: manifest.containerId,
    destination: manifest.destination,
    weight: manifest.unit == "lb"? manifest.weight * 0.45: manifest.weight,
    unit: "kg",
    hazmat: manifest.hazmat
  }
  return normalizedManifest;
}

function validateManifest (manifest){
  let validatedManifest = {}
  if (manifest.containerId === undefined){
    validatedManifest.containerId = "Missing";
  }else if(typeof(manifest.containerId) !== "number" || 
  manifest.containerId <= 0 || !Number.isInteger(manifest.containerId) ){
    validatedManifest.containerId = "Invalid";
  }

  if (manifest.destination === undefined){
    validatedManifest.destination = "Missing";
  }else if(typeof(manifest.destination) !== "string" || manifest.destination.trim() == ""){
    validatedManifest.destination = "Invalid";
  }

  if (manifest.weight === undefined){
    validatedManifest.weight = "Missing";
  }else if(typeof(manifest.weight) !== "number" || manifest.weight <= 0 || Number.isNaN(manifest.weight)){
    validatedManifest.weight = "Invalid";
  }

  if (manifest.unit === undefined){
    validatedManifest.unit = "Missing";
  }else if(manifest.unit !== "kg"){
    if(manifest.unit !== "lb"){
      validatedManifest.unit = "Invalid";
    }
  }

  if (manifest.hazmat === undefined){
    validatedManifest.hazmat = "Missing";
  }else if(typeof(manifest.hazmat) !== "boolean"){
    validatedManifest.hazmat = "Invalid";
  }
  return validatedManifest;
}

function processManifest(manifest){
  let processedManifest = normalizeUnits(manifest);
  
  if (Object.keys(validateManifest(processedManifest)).length == 0){
    console.log(`Validation success: ${processedManifest.containerId}`);
    console.log(`Total weight: ${processedManifest.weight} kg`);
  }else {
    console.log(`Validation error: ${processedManifest.containerId}`);
    console.log(validateManifest(processedManifest));
  }
}

processManifest(container0);

```

### Your browser information:

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

### Challenge Information:

Build a Cargo Manifest Validator - Build a Cargo Manifest Validator

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-v9/lab-cargo-manifest-validator/lab-cargo-manifest-validator)**
>
> Learn to Code for Free

GitHub Link: [freeCodeCamp/curriculum/challenges/english/blocks/lab-cargo-manifest-validator/69a56b5069ca99f7317e6e19.md at main · freeCodeCamp/freeCodeCamp · GitHub](https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/lab-cargo-manifest-validator/69a56b5069ca99f7317e6e19.md)

---

<div class="post-metadata">

**Author:** ![dhess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dhess/32/406235_2.png) [@dhess](https://forum.freecodecamp.org/u/dhess)\
**Post date:** [September 25, 2026, 8:07pm UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801089/2 "2026-09-25T20:07:28Z")

</div>

Welcome to the forum @niklasjansen02,

Have you tried testing with the data in failing Tests #23 and #24 to help you debug?

Happy coding

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [September 27, 2026, 8:08pm UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801089/3 "2026-09-27T20:08:25Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
