# 创建货物清单验证器 - 构建货物清单验证器

**URL:** <https://forum.freecodecamp.org/t/topic/802221>\
**Category:** Curriculum Help\
**Tags:** chinese-curriculum, javascript, chinese-中文\
**Created:** [October 14, 2026, 9:39am UTC](https://forum.freecodecamp.org/t/topic/802221 "2026-10-14T09:39:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laukkvan](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/laukkvan/32/422190_2.png) [@Laukkvan](https://forum.freecodecamp.org/u/Laukkvan)\
**Post date:** [October 14, 2026, 9:39am UTC](https://forum.freecodecamp.org/t/topic/802221/1 "2026-10-14T09:39:06Z")

</div>

### 告诉我们发生了什么：

My code is write according to the requirements . I don`t understand what`s wrong. who can help me look at it? The three function is it undefined.

### 你目前的代码

```js
function normalizeUnits(manifest){
  let newmainfest = {...manifest};

  if (newmainfest.unit === "lb"){
    newmainfest.weight = newmainfest.weight * 0.45;
    newmainfest.unit = "kg";
  }
  return newmainfest;
}

let manifest ={
  containerId: 55,
  destination: "Carmel",
  weight: 400,
  unit: "lb",
  hazmat: false
}

console.log(normalizeUnits(manifest));

function validateManifest(manifest){
  let newmainfest = {...manifest};
  let result = {};
  
  if(!("containerId" in newmainfest)){
    result.containerId ="Missing";
  }else if(!Number.isInteger(newmainfest.containerId) || newmainfest.containerId <= 0 ){
    result.containerId = "Invalid";
  }

  if (!("destination" in newmainfest)){
    result.destination ="Missing"
  }else if (typeof newmainfest.destination !== "string" || newmainfest.destination.trim() === ""){
    result.destination = "Invalid";
  }

  if (!("weight" in newmainfest)){
    result.weight = "Missing";
  }else if(typeof newmainfest.weight !== "number" || Number.isNaN(newmainfest.weight) ||
  newmainfest.weight <= 0){
    result.weight = "Invalid";
  }

  if(!("unit" in newmainfest)){
    result.unit = "Missing";
  }else if (newmainfest.unit !=="lb" && newmainfest.unit !=="kg"){
    result.unit ="Invalid"
  }

  if(!("hazmat" in newmainfest)){
    result.hazmat ="Missing";
  }else if(typeof newmainfest.hazmat !== "boolean"){
    result.hazmat = "Invalid";
  }

  return result;
}

console.log(validateManifest(manifest));

function processManifest(manifest){
let validation = validateManifest(manifest);

  if(typeof manifest === "object" && 
  manifest !== null && 
validation.containerId !=="Invalid"&& validation.weight !=="Invalid"&&
validation.unit !=="Invalid" &&
validation.hazmat !=="Invalid") {
  console.log(`Validation success: ${manifest.containerId}`);

  console.log(`Total weight: ${manifest.weight} kg`)
   }

}

console.log(processManifest(manifest));

```

### 你的浏览器信息：

用户代理是：`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 Edg/154.0.0.0`

### 挑战信息：

创建货物清单验证器 - 构建货物清单验证器

> **[freeCodeCamp.org](https://www.freecodecamp.org/chinese/learn/javascript-v9/lab-cargo-manifest-validator/lab-cargo-manifest-validator)**
>
> 免费学习编程

GitHub 链接：[https://github.com/freeCodeCamp/i18n-curriculum/blob/main/curriculum/challenges/chinese/blocks/lab-cargo-manifest-validator/69a56b5069ca99f7317e6e19.md](https://github.com/freeCodeCamp/i18n-curriculum/blob/main/curriculum/challenges/chinese/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:** [October 14, 2026, 1:10pm UTC](https://forum.freecodecamp.org/t/topic/802221/2 "2026-10-14T13:10:28Z")

</div>

Hi @Laukkvan,

Where in `processManifest` are you using` normalizeUnits` to return the weight in kg?

Happy coding
