7 Search for a Friend; Completely confused


#1

//I am reading through this forum and trying to copy/paste everyone else's working code, but just not getting it at all. //Here's where I gave up:

var friends = {
bill: {
firstName: "Bill",
lastName: "Dreckerson",
number: "208-886-0537",
address: ["217 Natalen","San Antonio", "78209"]

    },
steve: {
    firstName: "Steve",
    lastName: "Michaels",
    number: "208-885-0537",
    address: ["210 Presa","SATX", "78205"]
    },

};

var list = function(friends) {
for (var firstName in friends) {
console.log(friends[firstName]);
};

}

var search = function(name) {
for (var firstName in friends) {
if (name==="Bill") {
console.log(friends[firstName]);
return friends[firstName];
}
}
else {
console.log("Sorry, not found");
}
}


#2

What is the problem?


#3

With this code, I'm getting "SyntaxError: expected expression, got keyword 'else'"


#4

I had very similar code and just got through this by removing the "else {console.log....}" bit.It seems to not like the else. Other users on these forums seem pretty convinced this is a really buggy section. I am inclined to agree.

Hope this helps!