Javascript 我的职责不是识别正确的人

Javascript 我的职责不是识别正确的人,javascript,function,object,p5.js,Javascript,Function,Object,P5.js,这是它返回的结果,即使检查参数非常清楚。根据描述,罪犯应该是Jaunita Myrle。请帮助我确定问题是什么,因为我无法确定我的代码有什么问题: 以下是说明: Officer: 3357927 CaseNum: 701-1-60140847-3357927 Case 701 - Credible cat thief - stage 2 Kid they need you down at the precinct again. This time it's a sneaky cat thi

这是它返回的结果,即使检查参数非常清楚。根据描述,罪犯应该是Jaunita Myrle。请帮助我确定问题是什么,因为我无法确定我的代码有什么问题:

以下是说明:

Officer: 3357927
CaseNum: 701-1-60140847-3357927

Case 701 - Credible cat thief - stage 2

Kid they need you down at the precinct again.
This time it's a sneaky cat thief who has been absconding with the neighbourhoods felines for some time.
Luckily old Mrs Olivetti caught a glimpse of them as they disappeared over her back fence.
We’ve a bunch of likely characters lined-up but we need your brains to solve the mystery.

Please create a function that takes a suspect object as parameter from the data structure below.
Your function should return a boolean value indicating whether or not they match the witness statement.
You should use conditional statements to compare the suspect's properties to the statement.
It should only return "true" if the suspect matches the description in full.

The function is already being called in draw() but it is your job to implement it.

There are many possible ways of carrying out your duties,
but you should complete this task using ONLY the following
commands:

 - function testProperties(suspectObj){}
 - if()

Witness statement:

It all started when I was exiting the store. That's when I noticed them. I'm pretty sure they were above the age of 48. They had thin blond hair. Their expression seemed menacing. It's so hard to remember right now. The person I saw was male. They wore red glasses. They were quite big, they probably weigh more than 52 Kg. I'm not quite sure. That's all I can remember about them. 
代码如下:

var怀疑列表=[
{ 
“姓名”:“JENIFFER GOODBURY”,
“性别”:“女性”,
“表达式”:“空白”,
“头发”:“浓黑”,
“重量”:64,
“年龄”:62
},
{ 
“姓名”:“JAUNITA MYRLE”,
“性别”:“男性”,
“表达”:“威胁”,
“头发”:“薄金发”,
“重量”:62,
“年龄”:58
},
{ 
“名称”:“塔米卡·杜兰特”,
“性别”:“女性”,
“表情”:“悲伤”,
“头发”:“不”,
“重量”:100,
“年龄”:43
},
{ 
“姓名”:“LESLEY PORTOS”,
“性别”:“女性”,
“表情”:“愤怒”,
“头发”:“长长的白发”,
“重量”:92,
“年龄”:47
},
{ 
“姓名”:“杰奎琳·西尔维拉”,
“性别”:“男性”,
“表达式”:“空”,
“头发”:“剃光”,
“重量”:70,
“年龄”:21
}
];
var-myFont;
var背景img;
函数预加载(){
myFont=loadFont('speciallite.ttf');
backgroundImg=loadImage(“Background.png”);
}
函数设置()
{
createCanvas(640480);
textFont(myFont);
}
//在此声明您的函数
函数testProperties(SuspextObj)
{
if(suspectList.age>48&&suspectList.hair==“淡金发”和&suspectList.expression==“威胁”和&suspectList.gender==“男性”和&suspectList.weight>52)
{
返回true;
}
返回false;
}
函数绘图()
{
//您不需要更改此代码
图像(背景img,0,0);
for(设i=0;i}
好险啊!我想你有打字错误。在
testProperties
中,您可能是指
suspectObj
而不是
suspectList

function testProperties(suspectObj)
{
    if(suspectObj.age > 48 && suspectObj.hair == "thin blond" && suspectObj.expression == "menacing" && suspectObj.gender == "male" && suspectObj.weight > 52 )
    {
        return true;
    }
    return false;
}
var怀疑列表=[
{ 
“姓名”:“JENIFFER GOODBURY”,
“性别”:“女性”,
“表达式”:“空白”,
“头发”:“浓黑”,
“重量”:64,
“年龄”:62
},
{ 
“姓名”:“JAUNITA MYRLE”,
“性别”:“男性”,
“表达”:“威胁”,
“头发”:“薄金发”,
“重量”:62,
“年龄”:58
},
{ 
“名称”:“塔米卡·杜兰特”,
“性别”:“女性”,
“表情”:“悲伤”,
“头发”:“不”,
“重量”:100,
“年龄”:43
},
{ 
“姓名”:“LESLEY PORTOS”,
“性别”:“女性”,
“表情”:“愤怒”,
“头发”:“长长的白发”,
“重量”:92,
“年龄”:47
},
{ 
“姓名”:“杰奎琳·西尔维拉”,
“性别”:“男性”,
“表达式”:“空”,
“头发”:“剃光”,
“重量”:70,
“年龄”:21
}
];
函数testProperties(SuspextObj)
{
如果(suspextobj.age>48&&suspextobj.hair==“淡金发”和&suspextobj.expression==“威胁”和&suspextobj.gender==“男性”和&suspextobj.weight>52)
{
返回true;
}
返回false;
}

log(suspectList.map(s=>{return{name:s.name,test:testProperties(s)}}))谢谢!奇怪的是,这是他们告诉我们要使用的函数,所以我只是复制并粘贴了它。就个人而言,如果是您的代码或其他人的代码,当您在中添加新函数时,我建议您养成测试它的习惯。将一些好的数据和坏的数据传递给它,查看它是否按预期运行,否则进行修复/改进,然后继续。原因是,当您添加越来越多的函数时,发现问题变得越来越困难,除非您确保在这一点上一切正常。如果以上答案是您问题的解决方案,请随意用绿色复选标记:)祝您好运!