我有一点麻烦,为什么我的递归函数总是返回 false。const location = { name: "917", parentLocationCluster: { name: "Key Zones" ParentLocationCluster: { name: "Bla" } }}const test = CheckIfInKeyZone(location)const CheckIfInKeyZone = (parentLocationCluster) => { if(parentLocationCluster.name === 'Key Zones') { return true; } else if(parentLocationCluster.parentLocationCluster) { const { parentLocationCluster: location } = parentLocationCluster; CheckIfInKeyZone(location); } return false;}; 在parentLocationCluster.name === 'Key Zones' 被击中,在我期待的返回值是真实的,但它不是。帮助?
添加回答
举报
0/150
提交
取消