Oops, try again. It looks like your search function doesn't return contact information for Steve


#1

i cant make out the error in it

var friends = {
bill : {
firstName: 'Bill',
lastName: 'Gates',
number: 7896888944,
address:['One Microsoft Way','Redmond','WA','98052']
},
steve: {
fisrtName: 'Steve',
lastName: 'Jobs',
number: 9566193405,
address: ['One apple Way','Bodakdev','MA','18000']
}
};
var list = function(obj) {
for (var key in obj) {
console.log(key);
}
}
var search = function(name){
for (var i in friends) {
if (friends[i].firstName===name) {
console.log(friends[i]);
return friends[i];
}
}
};


#2

@kavyajeet,

Have close look at

fisrtName


#3

I'm having trouble with this one too. I passed it, but I'm not sure if I did it properly.

Anyway, what I did was pretty much the same as you except for the search function in the console and return I did this:

console.log(friends[i].address);
return friends[i].address);

As an aside, for the list function, I have "friends" as the object that the key loops through in the for/in loop. I ended up taking out that parameter with no errors.
var list = function(){
for (var key in friends){
console.log(key);
}
}
I don't really get what it's for yet.


#4

Now I see that everything I said is wrong after going through the lesson again from the beginning.

leonhard.wettengmx.n is right

Codecademy is great, and I appreciate that it's a free service. I hope they are aware of the problem of letting people pass even with the wrong answers (just look at mine above). Either way, I'm still grateful.


#5

i dont see the error still can be more specific


#6

@kavyajeet, @scriptrockstar36412,

+++ friends list and search and for-in explained.
Look here for an explanation
object
function
for-in-loop
list-function
search-function
http://www.codecademy.com/forum_questions/545275fd8c1ccc8e3e000a23#comment-5457b12c9c4e9d87cb00003f


#7

ok ok got it
i thought there was a mistake in my syntax
but when you come to know that its a spelling mistake, you feel great then :smiley: