# 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/801653>\
**Category:** freeCodeCamp Contributors\
**Created:** [October 3, 2026, 9:46am UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801653 "2026-10-03T09:46:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![husseinmusawi905](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/husseinmusawi905/32/422281_2.png) [@husseinmusawi905](https://forum.freecodecamp.org/u/husseinmusawi905)\
**Post date:** [October 3, 2026, 9:46am UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801653/1 "2026-10-03T09:46:50Z")

</div>

### Tell us what’s happening:

getting stuck on no.16 and 1, havent used const but think thats just a testing bug, 16 not sure how else to test it, no syntax or logic failures

### Your code so far

```js
function normalizeUnits(manifest) {
  let copy = {...manifest}
  if (copy.unit === "lb") {
    let newWeight = copy.weight * 0.45;
    copy.weight = newWeight;
    copy.unit = "kg";
  } else {
    return copy;
  }
  return copy;
}

function validateManifest(manifest) {
  let errors = {};
   if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) {
   return { manifest: "Invalid input type. Must be an object." }; 
  } 
  if (!manifest.hasOwnProperty("containerId")) {
    errors.containerId = "Missing";
  }else if (manifest.containerId === null || manifest.containerId <= 0 || typeof manifest.containerId !== "number" || !Number.isInteger(manifest.containerId)) {
    errors.containerId = "Invalid";
  }
  if (!manifest.hasOwnProperty("destination")) {
  errors.destination = "Missing";
} else if (typeof manifest.destination !== "string" || manifest.destination.trim() === "") {
  errors.destination = "Invalid";
}

  if (!manifest.hasOwnProperty("weight")) {
    errors.weight = "Missing";
  } else if (
  typeof manifest.weight !== "number" || !Number.isFinite(manifest.weight) ||
  manifest.weight < 0) { 
  errors.weight = "Invalid";
}

  if (!manifest.hasOwnProperty("unit")) { 
    errors.unit = "Missing";
  } else if (
    typeof manifest.unit !== "string" ||
    !["lb", "kg"].includes(manifest.unit.toLowerCase())
  ) {
    errors.unit = "Invalid";
  }

  if (!manifest.hasOwnProperty("hazmat")) {
    errors.hazmat = "Missing";
  } else if (typeof manifest.hazmat !== "boolean") {
    errors.hazmat = "Invalid";
  }

  return errors; 

} 

console.log(validateManifest({ containerId: -6,
  destination: 123,
  weight: 0,
  unit: 'pounds',
  hazmat: true })) 

```

### Your browser information:

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.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:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [October 3, 2026, 9:54am UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801653/2 "2026-10-03T09:54:23Z")

</div>

test 1 is checking 3 functions, one of which does not exist yet, so it fails

for test 16, double check the requirements, what are the valid unit and weight values? like, `KG`, `kg`, `kG`, are they all valid? what about a weight of 0?

---

<div class="post-metadata">

**Author:** ![orbitcoder79](https://avatars.discourse-cdn.com/v4/letter/o/3da27b/32.png) [@orbitcoder79](https://forum.freecodecamp.org/u/orbitcoder79)\
**Post date:** [October 4, 2026, 3:38am UTC](https://forum.freecodecamp.org/t/build-a-cargo-manifest-validator-build-a-cargo-manifest-validator/801653/3 "2026-10-04T03:38:52Z")

</div>

In your normalizeUnits function, check where return copy; is placed. Right now it is inside the else block. When copy.unit is “lb”, the function updates the values but never returns the object, resulting in undefined. You can move return copy; to the end of the function so it always returns the modified copy.

Also check if test 16 expects a specific conversion factor or rounding for normalizeUnits, or if it tests validateManifest with edge cases like missing properties or non-integer IDs.
