title: JavaScript loop an array - ReferenceError | i is not defined
body: <p>newbie at JavaScript and Postman here.</p>
  
  <p>I have set up a basic test in postman using JS to compare names in a web response to names in a data file. The array of names is in an external data csv file. </p>
  
  <p>I want to loop through the array, but I get an error:</p>
  
  <pre><code>"ReferenceError | i is not defined"
  </code></pre>
  
  <p>Code:</p>
  
  <pre class="lang-js prettyprint-override"><code>var newResponse = responseBody;
  
  let nameArray = data.name;
  
  for (let i = 0; i &lt; nameArray.length; i++) {
    console.log(nameArray.length);
  }
  
  pm.test("Web vs. Data: Person", function() {
    pm.expect(newResponse.Item[i].name).to.equal(nameArray.Item[i].person);
  });
  
  console.log(newResponse.Item[i].name);
  console.log(nameArray.Item[i].person);
  </code></pre>