title: How do you print out [{ and }] in JavaScript console.log() without the ["{ and the }"] in web page?
body: <p>I have trouble turning the input:</p>
  <pre><code>[&quot;apple&quot;, &quot;banana&quot;, &quot;carrot&quot;, &quot;durian&quot;, &quot;eggplant&quot;, &quot;apple&quot;, &quot;carrot&quot;] 
  </code></pre>
  <p>into the right output:</p>
  <pre><code>[{ name: &quot;Apple&quot;, count: 2 }, { name: &quot;Banana&quot;, count: 1 }, { name: &quot;Carrot&quot;, count: 2 }, { name: &quot;Durian&quot;, count: 1 }, { name: &quot;Eggplant&quot;, count: 1 }]
  </code></pre>
  <p>where I have trouble with the wrong output:</p>
  <pre><code>[&quot;{ name: &quot;Apple&quot;, count: 2 }, { name: &quot;Banana&quot;, count: 1 }, { name: &quot;Carrot&quot;, count: 2 }, { name: &quot;Durian&quot;, count: 1 }, { name: &quot;Eggplant&quot;, count: 1 }&quot;]. 
  </code></pre>
  <p>How can I have the right output:</p>
  <pre><code>[{ name: &quot;Apple&quot;, count: 2 }, { name: &quot;Banana&quot;, count: 1 }, { name: &quot;Carrot&quot;, count: 2 }, { name: &quot;Durian&quot;, count: 1 }, { name: &quot;Eggplant&quot;, count: 1 }] 
  </code></pre>
  <p>with the use of console.log() method?</p>
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
      &lt;h1&gt;Number of fruits 4&lt;/h1&gt;
        
        &lt;div id=&quot;output&quot;&gt;&lt;/div&gt;
  
       &lt;script&gt;
          
      var input = [&quot;apple&quot;, &quot;banana&quot;, &quot;carrot&quot;, &quot;durian&quot;, &quot;eggplant&quot;, &quot;apple&quot;, &quot;carrot&quot;];
          
          var A = 0;//to count the number of apples
          var B = 0;//to count the number of bananas
          var C = 0;//to count the number of carrots
          var D = 0;//to count the number of durians
          var E = 0; //to count the number of eggplants
     
           for (var i = 0; i &lt; input.length; i++)
            {
               if (input[i] == &quot;apple&quot;)
               {   
                 A += 1;  
                }
               if (input[i] == &quot;banana&quot;)
               {   
                 B += 1;  
                }
               if (input[i] == &quot;carrot&quot;)
               {   
                 C += 1;  
                }
               if (input[i] == &quot;durian&quot;)
               {   
                 D += 1;  
               }
               if (input[i] == &quot;eggplant&quot;)
               {   
                 E += 1;  
               }
             }            
          
         var apple1 = '&amp;quot;Apple&amp;quot;';
         var banana1 = '&amp;quot;Banana&amp;quot;';
         var carrot1 = '&amp;quot;Carrot&amp;quot;';
         var durian1 = '&amp;quot;Durian&amp;quot;';
         var eggplant1 = '&amp;quot;Eggplant&amp;quot;';
   
         var x1 = '{ name: ' + apple1 + ', count: ' + A + ' }';
         var x2 = ', { name: ' + banana1 + ', count: ' + B + ' }';
         var x3 = ', { name: ' + carrot1 + ', count: ' + C + ' }';
         var x4 = ', { name: ' + durian1 + ', count: ' + D + ' }';
         var x5 = ', { name: ' + eggplant1 + ', count: ' + E + ' }'; 
        
           var res1 = x1.split();  
           var res2 = x2.split();  
           var res3 = x3.split();  
           var res4 = x4.split();  
           var res5 = x5.split();    
  
           var output = [ res1 + res2 + res3 + res4 + res5 ];        
         
          console.log(&quot;output = &quot;, output);
          document.getElementById('output').innerHTML = JSON.stringify(output);
  
     &lt;/script&gt;
  
     &lt;/body&gt;
     &lt;/html&gt;
  </code></pre>