title: Accurate value from the JSON Array
body: <p>Trying to match the value with the JSON value by wrirting a for loop, but everytime once the loop is completes it is returning 2345 value only. Where am I going wrong can anyone help me out.
  And I have a term which dynamically generates a string value.</p>
  
  <pre><code>var mKey = doc.search.searchBy.split(",")[0].split("=")[1].replace(/\s+/, "").toLowerCase();
  </code></pre>
  
  <p>JSON:</p>
  
  <pre><code>{
      "records" : {
          "cat1" : [
              {
                  "id" : 1234,
                  "label":"a"
              },
              {
                  "id" : 2345,
                  "label":"b"
  
              }
          ],
          "cat2" : {
  
              "id" : 12345,
              "label" : "c"
          }
      }
  }
  </code></pre>
  
  <p>JS: </p>
  
  <pre><code>var array = doc.records.cat1;
  for (var i=0; i&lt;array.length; i++) {
      var oID = array[i].id.toString();
  }
  if (oID === "2345" &amp;&amp; mKey=="Apple") {
      console.log("Apple");
      break;
  }
  else if (oID === "1234" &amp;&amp; mKey=="Banana") {
      console.log("Banana")
  }
  else {
      console.log('other fruits');
  } 
  </code></pre>