Javascript: How to get object from object in an array
<p>Sample data:</p>

<pre><code>{
  "data": [
    {
      "name": {
        "full": "JOHN",
        "rank": "SENIOR"
      },
      "mobile": "12345"
    },
    {
      "name": {
        "full": "HENRY",
        "rank": "SENIOR"
      },
      "mobile": "67890"
    },
    {
      "name": {
        "full": "SAM",
        "rank": "JUNIOR"
      },
      "mobile": "54321"
    }
  ]
}
</code></pre>

<p>i'm trying to get the total number of senior members from the data sample above, and i can get the <strong>data.name</strong> and <strong>data.mobile</strong>, but i can't get the '<strong>rank</strong>' data from the parent 'name' object. can anyone please guide me to obtain the rank data. below is my javascript:</p>

<pre><code>function countRank(rank) {
    var i;
    for (i in rank.data) {
        if (rank.data[i] == "SENIOR") {
            i++;
        }
        document.getElementById('senior').innerHTML = 'Total senior members: ' + i;
    }
}
&lt;div id="senior"&gt;&lt;/div&gt;
</code></pre>
