title: How to get the sum of number from an array of objects, using pure JS?
body: <p>I want to show the <strong>total number of Likes</strong> using only pure JS.
  I grabbed the numbers from the JSON file but I don't know how to get the Total number of likes,
  I tried to use <strong>reduce</strong> method it didn't work maybe i am doing in the wron way</p>
  <p>This is what I want to do <a href="https://i.stack.imgur.com/jyYDt.jpg" rel="nofollow noreferrer">click here for the photo</a>
  This is my code</p>
  <pre><code>function photographerWork(JsonData, homeElement){
     const homeElt = homeElement.id;
     JsonData.media.forEach(element =&gt; {   
     if(homeElt == element.photographerId){
         const domDiv = document.getElementById('photographer-work');
         const newDiv = document.createElement(&quot;div&quot;);
         /////  the code i'am trying  ////
         const allTheLiks = element.likes
         console.log(allTheLiks)
         //////////////////////
         const workTemplate = `         
             &lt;div class=&quot;photo-box&quot;&gt; 
                 &lt;div class=&quot;photo&quot;&gt;
                     ${videoOrImage(element.image, element.video, element)}
                 &lt;/div&gt;   
                 &lt;div class=&quot;text&quot;&gt;
                     &lt;p&gt; ${element.tags}&lt;b&gt;${element.price} €  &amp;nbsp ${element.likes} &lt;i class=&quot;fas fa-heart&quot;&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;
                 &lt;/div&gt;
             &lt;/div&gt;
             `
         newDiv.innerHTML = workTemplate;
         domDiv.appendChild(newDiv);
         likesAndPrice(element, allTheLiks); 
       }
   })
  } 
  </code></pre>
  <p>This is my Result <a href="https://i.stack.imgur.com/ooDrJ.jpg" rel="nofollow noreferrer">click here</a><code>enter code here</code></p>
  <p>This is my JSON file example</p>
  <pre><code> &quot;media&quot;: [
        {
          &quot;id&quot;: 342550,
          &quot;photographerId&quot;: 82,
          &quot;image&quot;: &quot;../Photos/Tracy/Fashion_Yellow_Beach.jpg&quot;,
          &quot;tags&quot;: [&quot;fashion&quot;],
          &quot;likes&quot;: 62,
          &quot;date&quot;: &quot;2011-12-08&quot;,
          &quot;price&quot;: 55
        },
        {
          &quot;id&quot;: 8520927,
          &quot;photographerId&quot;: 82,
          &quot;image&quot;: &quot;../Photos/Tracy/Fashion_Urban_Jungle.jpg&quot;,
          &quot;tags&quot;: [&quot;fashion&quot;],
          &quot;likes&quot;: 11,
          &quot;date&quot;: &quot;2011-11-06&quot;,
          &quot;price&quot;: 55
        },
        {
          &quot;id&quot;: 9025895,
          &quot;photographerId&quot;: 82,
          &quot;image&quot;: &quot;../Photos/Tracy/Fashion_Pattern_on_Pattern.jpg&quot;,
          &quot;tags&quot;: [&quot;fashion&quot;],
          &quot;likes&quot;: 72,
          &quot;date&quot;: &quot;2013-08-12&quot;,
          &quot;price&quot;: 55
        },
        {
          &quot;id&quot;: 9275938,
          &quot;photographerId&quot;: 82,
          &quot;image&quot;: &quot;../Photos/Tracy/Event_WeddingGazebo.jpg&quot;,
          &quot;tags&quot;: [&quot;events&quot;],
          &quot;likes&quot;: 69,
          &quot;date&quot;: &quot;2018-02-22&quot;,
          &quot;price&quot;: 55
        },
        {
          &quot;id&quot;: 2053494,
          &quot;photographerId&quot;: 82,
          &quot;image&quot;: &quot;../Photos/Tracy/Event_Sparklers.jpg&quot;,
          &quot;tags&quot;: [&quot;events&quot;],
          &quot;likes&quot;: 2,
          &quot;date&quot;: &quot;2020-05-25&quot;,
          &quot;price&quot;: 55
        },
  </code></pre>