Code works and prints but lesson does not pass. Here is my c


#1



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


Error:
Oops, try again. It looks like your search function doesn't return contact information for Steve.

friends = [
      {
        firstName: "bill",
        lastName: "hader",
        number: "213-459-0000",
        address: ['111','small st','dallas','tx','77777']
    },
     {
        firstName: "steve",
        lastName: "smith",
        number: "513-459-0000",
        address: ['111','big st','dallas','tx','77777']
    }
 ];
    
    // var list = function(){
    //   for(firstName in friends){
    //   console.log(firstName);
    //   }
    // };
    // list();
    var search = function(name){
      for(i in friends){
          if(friends[i].firstName  === name){
              var name = friends[i].firstName;
              var lastName = friends[i].lastName;
              var fullName = name + ' ' + lastName;
              var number = friends[i].number;
              var address = friends[i].address;
              var contact = name + ' ' + lastName + ' ' + number + ' ' + address;
              console.log(contact);
              return contact;
            
          }
      }
     
    };
  search('steve');


#2

@javarockstar70270,
In the prior section's
you were asked to define the friends object
as having a property-key 'steve'
as having its property defined
as having a firstName property-key with an associated capitalized "Steve" string Value

=========================================

var friends= {
              bill: { firstName: 'Bill',
                      lastName: 'Gates',
                      number: '444-444-4444',
                      address: [ 'One Microsoft way', 'Redwood', 'WA' ]
              },
             steve: {
                      firstName: 'Steve',
                      lastName: 'Jobs',
                      number: '333-333-3333',
                      address: [ 'Two infinite loop', 'Bentown', 'DV' ] 
              }
   };

keep repeating these two lines
An object has one or more properties seperated by a comma-,
Each property consists of a property-key and it's associated value

Description of the friends object.
The friends object has 2 properties and are seperated by a comma-,

there is a bill property with property-key bill and it's associated object value
(this associated object has 4 properties, the property-keys being firstName, lastName,number and address)
there is a steve property with property-key steve and it's associated object value
(this associated object has 4 properties, the property-keys being firstName, lastName,number and address)

access via dot-notation == only literal property-key allowed

friends.bill ==> you will get the associated value of the bill property-key, thus
you get the object with 4 properties

friends.bill.lastName ==> you will get the associated value of the lastName property-key

access via the square-bracket-notation == literal & VARIABLE

1 using the literal property-key

friends["bill"]
friends["bill"]["lastName"]

2 using the property-key by reference (=== via a variable )

var propertyKey1 = "bill";
var propertyKey2 ="lastName";
friends[propertyKey1] ==> you will get the associated value of the bill property-key, thus
you get the object with 4 properties

friends[propertyKey1][propertyKey2]
in this case you will get the string VALUE of the lastName property
of the associated object VALUE of bill


#3

@javarockstar70270,

+++ friends list and search and for-in explained.
Look here for an explanation
object
function
for-in-loop
list-function
search-function
http://www.codecademy.com/forum_questions/545275fd8c1ccc8e3e000a23#comment-5457b12c9c4e9d87cb00003f