title: Compare two json objects with value key in javascript (React JS)
body: <p>I have below array of objects</p>
  <pre><code>dateAry = [{name: 'date from', value: 'datefrom'},{name: 'date to', value: 'dateto'}]
  </code></pre>
  <p>Here datefrom is '15/07/2021' and dateto is '15/06/2021'</p>
  <p>I want to compare the dates values. If 'to date' is less than of 'from date', I want to display an error message.</p>
  <p>I tried the below approach so far</p>
  <pre><code> if(dateAry[0].value &amp;&amp; dateAry[1].value){  // how to set loop without using index values?
       var fromDt = new Date(dateAry[0].value);
       var toDt = new Date(dateAry[1].value);
           if (endDt &lt;= strtDt) {
               alert(&quot;true&quot;);  // nothing is working here as expected
            }
    }
  </code></pre>
  <p>I am new to JavaScript, so please help what I am doing wrong or is there any better approach?</p>