7.search for a friend


#1



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


I tried already several ways to fix the problem but the code doesn't give the correct result. In this case it says "It looks like you have an error in your code! Check the message for more details: ReferenceError: Alona is not defined".

Please help me to understand what im doing wrong, wanna see it working :slight_smile:
Thanks!


var friends = {
    
bill: {
    firstName: "Bill",
    lastName: "Banana",
    number: "(155) 522-4444",
    address: ["street", "houseNr", "postcode"]
    },  
steve: {
    firstName: "Steve",
    lastName: "Apple",
    number: "(333) 4444-555",
    address: ["street", "houseNr2", "postcode2"]
    },   
alona: {
    firstName: "Alona",
    lastName: "Orange",
    number:"(555) 8888-777",
    address: ["street", "houseNr3", "postcode3"]
    },  
};
var list = function (friends) {
    for(var i in friends){
        console.log(i);
        }
    }
    
    var search = function(name) {
        for(var i in friends) {
            if (friends[i].firstName === name){
                console.log(friends[i]);
                return friends[i];
                }
            
            }
        }
        
        search(Alona);


#2

var list = function(object){
for (var key in object){
console.log(key);
}
}
list();


#3

you where so close, this line:

search(Alona);

Alona is not a variable, it is a string, use quotation marks (")


#4

hahaha
noway!!!
thanks!