Listing Everybody....Not!


#1

I looked in the forms to see if anyone else had this issue but didn’t come across it.
I did however see other issues people were having & when looking at their code for the list function none looked like mine.
I passed the lesson but didn’t have a console log of any kind & didn’t use contacts.length.
I made my code look like theirs with the suggested corrections to their code hoping to have something log on the console without success.
Is my code correct?
Was something supposed to log on the console?

https://www.codecademy.com/courses/building-an-address-book/0/4?curriculum_id=506324b3a7dffd00020bf661#



![Screenshot (10)_LI|690x387](//codecademy-discourse.s3.amazonaws.com/original/5X/f/e/e/6/fee6fb79d94f1ea52b1f2f1fbf4c43dfd9ec56d1.jpg)

#2

After getting to the next lesson the list function code was changed to what I assume is supposed to be the correct code. So I copied it & went back to try it - it logged but gave me the following
error message:

Oops, try again. Your code threw the following error when trying to call list(): TypeError: Cannot read property ‘length’ of undefined

This is the code the lesson had listed:

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


#3

I discovered the correct code!
My function call was the problem with the lesson’s correct code.
The correct call is simply list(contacts);
This call did not work with my original incorrect code.
I assume that my incorrect code enabling me to pass the lesson is a sign of a “bug”.
Just glad the correct code was revealed in a later lesson!
:v:


#4

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