It looks like you didn't log to the console


#1

I am stuck in the same spot. I think I have the same code. It just keeps saying, "It looks like you didn't log to the console." No duh. But I don't know why!

Here's my code - it should look very familiar. I've checked capital letters, ===, semicolons... What am I missing?

var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "bob.jones@example.com"
};

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
console.log(person.firstName + " " + person.lastName);
}

function list() {
var contactsLength = contacts.length;
for (var i = 0; i < contactsLength; i++) {
printPerson(contacts[i]);
}
}

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


5. Finding that Special Someone
#2

Hey there! In your for-loop you've written contacts.Length but this should be contacts.length.

If you write .Length the length-function won't be recognised as the .length funtion.


#3

For the record, .length is a property/attribute, not a function.


#4

Thanks! I knew it would be something stupid like that. I should have tried learning this stuff before I turned 46 and my eyes stopped working. I'm very grateful to all the folks who are willing to help with that kind of tedious checking for us old newbies. :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.