title: Javascript for loop not getting length inside another for loop
body: <p>I am trying to loop through my json value obtain from my server which is like this:</p>
  
  <pre><code>  [
      {
      below_min: [
      {
      y: 0,
      label: "Bhagalpur",
      color: "Red"
      },
      {
      y: 0,
      label: "Gopalganj",
      color: "Red"
      }
      ]
      },
      {
      min: [
      {
      y: 0.2,
      label: "Samastipur",
      color: "Orange"
      },
      {
      y: 0.3,
      label: "Saran",
      color: "Orange"
      }
      }
      ]
      }
  ]
  </code></pre>
  
  <p>I am using this loop code to get the value of my below_min array: </p>
  
  <pre><code>  for (let index = 0; index &lt; res.length; index++) {
          const element = res[index];
          console.log(element.below_min);  
          // const u = element.below_min
  
          for (let index = 0; index &lt; element.below_min.length; index++) {
              const h = element.below_min[index];
  
          }
  
      }
  </code></pre>
  
  <p>but I am getting error:</p>
  
  <pre><code> ERROR TypeError: Cannot read property 'length' of undefined
  </code></pre>
  
  <p>I have tried few things such as when I am trying to see what is this below_min as type of I am seeing this as an object. My question is what is wrong with my code.</p>