Contact list 5/6 List em all auto print


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-3bmfN/0/6?curriculum_id=506324b3a7dffd00020bf661


Code shown as correct, however, it auto print without me call the list. When I call the list, it adds up another pair of values


var friends = {
    bill: {
        firstName: 'Bill',
        lastName: 'gates',
        number: '121212',
        address: ['One Microsoft Way', 'WA', 12123]
    },
    steve: {
        firstName: 'Steve',
        lastName: 'Jobs',
        number: '41422122',
        address: ['Apple Highway', 'CA', 41423]
    },
}

var friends2 = {
    a: "absbs",
    b: "12wefa"
}

var list = function(object) {
    for (var key in object){
        console.log(key);
        }
    }


#2

Here:

You didn't define the variable object. The only object defined is friends, right?


#3

hm.. not exactly. I have 2 objects to test this problem, friends and
friends2.
Are you trying to say if I define the object by calling list(friends), it
will only show one set of value instead of 2 sets?


#4

What I am saying is that the exercise before this requires you to create an object of two friends (bill and steve), which you have done. While this exercise requires you to create a list function that takes in a single argument, friends, your argument is object which isn't defined.

That said, there is no need for an object friends2.

[If you want to use the two friends, then they should be your arguments...]


#5

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