Tell us what’s happening:
Hello I still i did’nt get the step 7 and 14 I run sow many times still can’t find the bugs could you mentions any erros
Your code so far
const manifest = {
containerId: 68,
destination: "Salinas",
weight: 101,
unit:"lb",
hazmat: true
}
function normalizeUnits(manifest){
const copyManifest = {...manifest}
const convert = 0.45;
let result = new Object();
if(copyManifest.unit === "lb"){
result = copyManifest.weight * convert;
copyManifest.weight = result;
copyManifest.unit = "kg";
}
return copyManifest ;
}
//Could you help me what this code not unable to pass 7 and 14 it already works but it did'nt pass yet
function validateManifest(manifest){
let empty = {}
let container = ["containerId", "destination", "weight", "unit", "hazmat"]
for(let key of container) {
const value = manifest[key];
if ( value == null ) {
empty[key] = "Missing";
}
else if (key === "containerId" && (!Number.isInteger(value) || value <= 0)) {
empty[key] = "Invalid";
}
else if(key === "destination" && value !== "Santa Cruz"){
empty[key] = "Invalid";
}
else if(key === "weight" && (Number.isNaN(value) || value <= 0)) {
empty[key] = "Invalid";
}
else if(key === "unit" && (value!== "kg") && (value !=="lb")) {
empty[key] = "Invalid";
}
else if(key === "hazmat" && (typeof value !== "boolean")){
empty[key] = "Invalid";
}
}
return empty;
}
//console.log(chr, shallowCopyManifest[chr])
//console.log(normalizeUnits())
console.log(validateManifest({}));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0
Challenge Information:
Build a Cargo Manifest Validator - Build a Cargo Manifest Validator