#7 - Search for Friend - Passed, but more output than required


#1



I get a 'pass' but my output includes all items from the object, not just the name, and this is if my search is equal to a first name or not.

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

Output Received:
Name not found.
{ firstName: 'Steve',
lastName: 'Wachovinak',
number: '(703) 555-1212',
address: [ '6200 Anderson Ave.', 'Luberville, AK', '34349' ] }
Name not found.
{ firstName: 'Steve',
lastName: 'Wachovinak',
number: '(703) 555-1212',
address: [ '6200 Anderson Ave.', 'Luberville, AK', '34349' ] }
{ firstName: 'Bill',
lastName: 'Gates',
number: '206) 555-1212',
address: [ '12 Forteen Palm Ave', 'Justicevill, FL', '22204' ] }
{}


var friends = new Object ();
friends.bill = new Object ();
friends.steve = new Object ();
var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "206) 555-1212",
        address: ['12 Forteen Palm Ave', 'Justicevill, FL', '22204']
    },
    steve: {
        firstName: "Steve",
        lastName: "Wachovinak",
        number: "(703) 555-1212",
        address: ['6200 Anderson Ave.', 'Luberville, AK', '34349']
    },
};
var list = function (friends){
    for (var firstName in friends){
        console.log(firstName);
      
    }
    
}
var name = prompt ("Please enter the first name.", "Enter the first name here");
var search = function (name){
    for (var firstName in friends)
    if (friends[firstName].firstName === name ){
        console.log (friends[firstName]);
        return friends[firstName];
    }
    else {
        console.log ("Name not found.")
    }
    
}


#2

@ajaxwhiz07943,
-1
In some sections of this course, the course-checker Display's data
this you could then identify by placing two EXTRA code-line's:
console.log( "== My End ==" );
console.log( "== All that is displayed now, is the course-checker ==" );
-2
In your search function
remove the ELSE statement and its code-block