5/6 returning both names


#1

When I execute the code, I return both names (Bob & Mary) but I am not sure why.

Does it have to do with the variable in the for function?

var search = function(lastName){
var familyName = contacts.length;
for (var i = 0; i < familyName; i++){
if(lastName === contacts[i].lastName);{
printPerson(contacts[i]);
}
}
}; search("Jones");


#2

Hi, am about 98% sure i have the solution to your problem. I hope it works for you, because i ran your code and tried finding what was wrong, then i saw the solution.

Your former code :

if(lastName === contacts[i].lastName);

Now try removing the semicolon immediately after your if statement.

if(lastName === contacts[i].lastName)

Would be happy if this helps.Thanks.


#3

Thanks Samge0rge! This was the fix!