8. Victory!


#1

var friends = new Object();
friends.bill = {
firstName: "Bill",
lastName: "Withers",
number: "1",
address: ['Canada', 'Canada', 'Canada', '226232']
};
friends.steve = {
firstName: "Steve",
lastName: "Higgens",
number: "2",
address: ['Detroit', 'Detroit', 'Detroit', '3387648']
};
var list = function(friends){
for(var key in friends) {
console.log(key)
}
};
var name = ["Steve", "Bill"];
var search = function(name){
for (var key in friends){
if(friends[key].firstName === name){
console.log(friends[key]);
return friends[key];
}
}
};
After using this same exact code for lesson 7 and having it show all the contact info for each person, in lesson 8 the console only displays
{"firstName":"Steve","lastName":"Higgens","number":"2","address":["Detroit","Detroit","Detroit","3387648"]}


#2

This line is not in the instructions. It is also not valid in global scope since that variable is a property of the window object and can only be set internally. name can only be used as a variable inside a function.

You are not using the data given in the instructions, so why should we take this seriously?


#5

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