6/8 Help


#1

Could someone tell me what is wrong with my code?

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Jobs",
        number: "(828) 553-6206",
        address: ['Four Main Street','Springfield','MO','63682']
    },
    
    steve: {
        firstName: "Steve",
        lastName: "Gates",
        number: "(889) 838-5261",
        address: ['Ten Second Street','Colombia','MO','55546']
    }
};
var list = function (friends) {
    for (var key in object) {
        console.log(key);
    };
}
list(bill)

Throws:
Oops, try again. Did you create a function called list?

In Console:
ReferenceError: bill is not defined


#2

I'm having trouble with the list as well. This is what I've got:
var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ["One Microsoft Way", "Redmond", "WA", "98052"]
}
steve: {
firstName: "Steve",
lastName: "Hardy",
number: "(508) 555-5555",
address: ["Three Feud Road", "Leff City". "NY", "95120"]
}
};
var list = function(friends) {
for (var key in friends) {
console.log(key)
}
};

I can't figure this out for the life of me.


#3

that is correct, just don't call the function at the end


#4

steve: {
firstName: "Steve",
lastName: "Hardy",
number: "(508) 555-5555",
address: ["Three Feud Road", "Leff City". "NY", "95120"]
}

@eric_pherigo, You have a "." between Leff City and NY in your array. That should be a comma ",". Not sure if that will solve everything else, but that would be an array/syntax issue.


#5

I am getting the same error. What did I do wrong?

var friends = {
    bill: {
        firstName:"Bill",
        lastName:"Gates",
        number:"(305) 451-2296",
        address: ["5727 Malcom Way", "Onslow", "NC", "34205"]},
    steve: {
        firstName:"Steve",
        lastName:"Jobs",
        number:"(823) 385-1846",
        address: ["3 Harris Street", "Banton", "OH", "38529"]},
    tricia: {
        firstName:"Katricia",
        lastName:"Moore",
        number:"(384) 386-1279",
        address: ["4629 Riley Way", "Canton", "NE", "28429"]}
    };
var list = function (search){
    for (var enter in object)
        {console.log(enter)
        };
    };

#6

Hi there I have managed to figure it out.

I have constructed my object differently but the same rules apply.

my code below:

var friends = new Object(); {
friends.bill = new Object(); {
friends.bill.firstName = 'Bill',
friends.bill.lastName = 'Gates',
friends.bill.number = '0782378497456'
friends.bill.address = ['One Microsoft Way','Redmond','WA','98052']
}
friends.steve = new Object(); {
friends.steve.firstName = 'Steve',
friends.steve.lastName = 'Jobs',
friends.steve.number = '079882319863'
friends.steve.address = ['1 Infinite Loop', 'Cupertino, California', 'United States']
}
};

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

I have added nothing to the function ()
but have added the object name and log the friend Key.

I have tried it will also putting something in the function for instance:

var list = fuction(friends) {
}

this works the same.

If anyone has a better way of doing this please let me know but this has worked for me


#7

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 666-6666",
address: ['Barber Avenue', 'Seattle', 'WA', '94543']

   },
steve: {
    firstName: "Steve",
    lastName: "Jobs",
    number: "(510) 666-6666",
    address: ['Piedmont Avenue', 'Cupertino', 'CA', '94563']
    }
var list = function(stuff) {
    for(var key in friends) {
        console.log(key);
    }
};

My code doesn't work either. Anybody know whats wrong? It returns syntax error: unexpected var token.


#8

never mind I figured it out. I forgot a { bracket thing.


#9

Hey there ! Everything is correct just include ',' at the end of key bill in friends object after creation of bill object in friends!


#10

Thanks, I can't believe I missed that