function validateManifest(manifest){
let containera = [
“containerId”,
“destination”,
“weight”,
“unit”,
“hazmat”,
]
let result = {};
for(let key of containera){
if(manifest[key] == null) {
result[key] = “Missing”
}
else if (
(key === “containerId” && (!Number.isInteger(manifest[key]) || manifest[key] <= 0 ) ) ||
(key === “destination” && manifest[key]!== “Santa Cruz”) ||
(key === “weight” && (typeof manifest[key] !== “number” || Number.isNaN(manifest[key]) || manifest[key] <= 0)) ||
(key === “unit” && manifest[key] !== “kg” && manifest[key] !== “lb”) ||
(key === “hazmat” && typeof manifest[key] !== “boolean”)
) {
result[key] = “Invalid”;
}
}
return result;
}
//console.log(chr, shallowCopyManifest[chr])
//console.log(normalizeUnits())
console.log(validateManifest({ containerId: 1, destination: “Santa Cruz”, weight: 304, unit: “kg”, hazmat: false
}));
