title: How to calculate the data in JSON?
body: <p>The essence is that I have json file:</p>
  <pre><code>[
      {
          &quot;id&quot;: 0,
          &quot;username&quot;: &quot;Antony&quot;,
          &quot;users&quot;: [
              {
                  &quot;id&quot;: 1,
                  &quot;like&quot;: 0
              },
              {
                  &quot;id&quot;: 2,
                  &quot;like&quot;: 1
              },
              {
                  &quot;id&quot;: 3,
                  &quot;like&quot;: 0
              },
              {
                  &quot;id&quot;: 4,
                  &quot;like&quot;: 1
              }
          ]
      },
      {
          &quot;id&quot;: 1,
          &quot;username&quot;: &quot;Janet&quot;,
          &quot;users&quot;: [
              {
                  &quot;id&quot;: 0,
                  &quot;like&quot;: 0
              },
              {
                  &quot;id&quot;: 2,
                  &quot;like&quot;: 1
              },
              {
                  &quot;id&quot;: 3,
                  &quot;like&quot;: 1
              },
              {
                  &quot;id&quot;: 4,
                  &quot;like&quot;: 1
              }
          ]
      },.......
  </code></pre>
  <p>I need to count how many &quot;likes&quot;, have each user.
  ie:
  For example, take the first id == 0.
  We pass on the object, which can be very much and look:
  If id == 0 and like == 1, add 1 to the array.
  In the end, I must have:
  <strong>usersWithLikes [id User] = number of likes for all objects</strong>
  For example:</p>
  <blockquote>
  <p>usersWithLikes [0] = 3</p>
  <p>usersWithLikes [1] = 1</p>
  <p>usersWithLikes [2] = 4</p>
  <p>usersWithLikes [3] = 0</p>
  </blockquote>
  <p>At the moment, I think so:</p>
  <p>thumbsUp_data - json data</p>
  <pre><code>var usersWithLikes = thumbsUp_data.map(function(user_data){
                      return user_data.users.filter(function(value){
                          return value.like == 1;
                      }).length;
                  });
  </code></pre>
  <p><strong>But this is not correct, because it considers how many likes the object.
  Help with the decision ...</strong></p>