title: How can I display an image in a JS array?
body: <p>Every method I try, I receive either underfined, or the description of the item, not the picture itself. Here's my code (with the different methods I've tried):</p>
  <p>Add
  show all<br /></p>
  <pre><code>  &lt;label for=&quot;Name&quot;&gt;Name&lt;/label&gt;
    &lt;input id=&quot;Name&quot; /&gt;&lt;br /&gt;
    &lt;button onclick=&quot;searchByName()&quot; class=&quot;btn btn-info&quot;&gt;
      Search by Name
    &lt;/button&gt;
    &lt;input id=&quot;Search&quot; /&gt;
    &lt;label for=&quot;Search&quot;&gt;Search&lt;/label&gt;
    &lt;br /&gt;
    &lt;div class=&quot;alert alert-primary&quot; id=&quot;display&quot;&gt;&lt;h1&gt;My Contacts&lt;/h1&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;!-- &lt;img id=&quot;imgFemale&quot; src=&quot;images/female-icon-7897.png&quot;&gt;
  &lt;img id=&quot;imgMale&quot; src=&quot;images/person-icon-1687.png&quot;&gt; --&gt;
  &lt;script&gt;
    const imgFemale =&quot;images/female-icon-7897.png&quot;
    const imgMale = &quot;images/person-icon-1687.png&quot;
   
    let myContacts = [
      { Name: &quot;Hubby &quot;, gender: &quot;male&quot;, Image: imgFemale.src=&quot;images/person-icon-1687.png&quot;},
      { Name: &quot;Mom&quot;, gender: &quot;female&quot;, img: imgFemale.value },
      { Name: &quot;Shannon&quot;, gender: &quot;female&quot;, img: [imgFemale].innerHTML },
      { Name: &quot;Dad&quot;, gender: &quot;male&quot;, img: imgMale },
    ];
    function add() {
      console.log(&quot;add pressed&quot;);
      myContacts.push({
        id: myContacts.length + 1,
        Name: Name.value,
      });
    }
  
    function showAll() {
      console.log(&quot;showAll pressed&quot;);
      display.innerHTML = &quot;&lt;h1&gt;My Contacts&lt;/h1&gt;&quot;;
      for (let index = 0; index &lt; myContacts.length; index++) {
        display.innerHTML += `&lt;div class='alert alert-${myContacts[index]}'&gt;
          &lt;button class=&quot;btn btn-danger&quot; onClick='remove(${index})'&gt; Delete &lt;/button&gt; 
          ${myContacts[index].Name} , ${myContacts[index].gender} , ${myContacts[index].img}&lt;/div&gt;`;
      }
    }
  </code></pre>