7.Search for a friend


#1

Hello, can someone please tell me what I've been doing wrong? An error keeps popping up asking me if I created a function or not. Help Please!
var list = function(friends) {
for (var key in friends) {
console.log(key);
}
var search = function(name) {
for (var key in friends) {
if(friends[key].firstName === name) {
console.log(friends[key]);
list(friends);
search("Steve");
}
}
}
};


#2

Your syntax is messed up; you forgot to end your list function.

var list = function(friends) {
  for (var key in friends) {
    console.log(key);
  }
};
var search = function(name) {
  for (var key in friends) {
    if (friends[key].firstName === name) {
      console.log(friends[key]);
    }
  }
};
list(friends);
search("Steve");

#3

@dantemp Thank You for your helpful response