Javaseript object


#1


why output is [object Object]?

``
 <script>
    var friends = {};
    friends.bill = {
      firstName: "Bill",
      lastName: "Gates",
      number: "(206) 555-5555",
      address: ['Microsoft Way']
      };
    friends.steve = {
      firstName: "Steve",
      lastName: "Jobes",
      number: "(444) 111 000",
      address: ["Apple way"]
    };
    var list = function(obj) {
      for( var key in obj){
        console.log(obj);
      document.getElementById("demo").innerHTML += key + "<br>";
      }
    }

    var search = function(name) {
      for(var key in friends){
        if(name === friends[key].firstName){
          console.log(friends[key]);
          document.getElementById('search').innerHTML += friends[key] + "<br>";
        }
      }
    }
    // list(friends);
    search("Steve");
  </script>


#2

@arcsurfer28970,
Have a read
https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
reading the syntax-section

 element.innerHTML = content;

Removes all of element's children, 
parses the content string 
and assigns the resulting nodes as children of the element.

thus

document.getElementById('search').innerHTML = friends[key] + "<br>";

#3

I did not understand what you mean
Can you change the code and gave me the correct code