5/6 returning both names


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);{
}; search("Jones");


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.


Thanks Samge0rge! This was the fix!