7. Search for a friend


#1


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

I do get this exercise, but, becasue I am a noob, I dont know how to execute it. What is wrong with my code?


var friends = {
    Bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ["Apple", "Apple1", "Apple3"]
    },
    Steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(206) 555-5556",
        address: ['Micro', 'Micro', 'Micro']
    }
};
var list = function(){
    for (var key in friends){
        console.log(key)
    }
}
var search = fucntion(name){
    for(var key in obeject){
        if(friends[key].firstName === name){
            console.log(friends[key]);
            return friends[key];
        }
    }
}
list(friends);
search("steve")


#2

You forgot the semicolon after console.log(key)

Again you forgot the semicolon. Just make sure that you have semicolons in the proper places, it is a very common mistake to forget them which is one of the reasons why I like Python and Swift so much. I hope this helped you and you don't have any more problems with that exercise :slight_smile:


#3

There's a typo in the word 'function'


#4

I didn't notice that part :slight_smile: good spot.


#5

Thank you!, I was that simple :slight_smile:


#6

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