7. Search for a friend, help!



TypeError: Cannot read property 'firstName' of undefined

Oops, try again. Did you create a function called search?

var search = function(name) {
    for(var key in name) {
        if(friends[key].firstName === name) {
            return friends[key]
            } else {
                return "Friend was not found";



Here. You need to replace 'key' and 'name' with the appropriate terms. The hint does this to ensure user participation.

var search = function(name) {
for (firstName in friends) {
if (friends[name].firstName === name) {
return friends[key];

BTW, F1rst P0st!


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