Logging wrong address?


#1

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


Why does my code return ["234 E Ave.","Rootmont","MI","87345"]? It logs "Bill" and "Steve" as it should, but then adds that address.


var friends = new Object();
friends.bill = new Object();
friends.steve = new Object();
friends.bill.firstName= "Bill";
friends.bill.lastName= "Wilick";
friends.bill.number= "(222) 222-2222";
friends.bill.address= ['214 W Ave.', 'Richmont', 'WA', '12345']
friends.steve.firstName= "Steve";
friends.steve.lastName= "Wilock";
friends.steve.number= "(232) 222-2232";
friends.steve.address= ['234 E Ave.', 'Rootmont', 'MI', '87345']

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


#2

key is meant to be a word that you change to what you used in your code. so for mine the text says var friend in friends. I use the other version for making objects so this is really confusing for me but I think this should help.


#3

Thanks. But why does my code still log Steve's address: ['234 E Ave.', 'Rootmont', 'MI', '87345']


#4

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