Search Help!


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#


I am on the search function and I keep getting an error even though it matches the hint please help.


var friends = new Object();

friends.bill= {
    firstName: "Bill",
    lastName: "Gates",
    number: "555-555-5555",
    address: ['Microsoft', 'xbox', 'WA']
    };

friends.steve = {
    firstName:"Steve",
    lastName: "Jobs",
    number:" 543-333-3333",
    address: ['Apple', 'Tree', 'CA']
    };
    
    
    
var list = function(obj){
    for(val in obj)
    {
        console.log(val);
    }
};

var search = function(name){
    for(var person in friends)
    { 
        if(friends[person].firstname === name)
        {
            console.log(friends[person]);
            return friends[person];
        }
    }
};

search("Steve");


#2

@caleb.hatcher, look to this line:

if(friends[person].firstname === name)

and look to your properties in obj friends.
Do you have property firstname?


#3

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