title: A for-loop that compares two arrays looking for matching values
body: <p>I have two arrays that I need to check against each other and if they have reached a point where both items in each array are actually the same as one another, then append some html somewhere.</p>
  
  <p>Here are some bits of the code I have been trying as an example:</p>
  
  <pre><code>var daysArray = ["1", "2", "3", "4", "5"];
  var courseHwork = ["4", "8", "15", "16", "23", "42"];
  </code></pre>
  
  <p>so in the arrays above there is only one matching value, being: "4"</p>
  
  <p>here's the next part:</p>
  
  <pre><code>for (var i = 0; i &lt; courseHwork.length; i++) {
  //in my actual code courseHwork contains several objects, each of which 
  //has a duedate property, so here I want to see if this part of the duedate 
  //property is equal to any position in the daysArray array.
     if (courseHwork[i].duedate.substring(8,10) === daysArray[i]) {
  //here I mean to select an element of this class that contains a string 
  //that is equal to that of the matching positions in both arrays. then 
  //once found it should take the title property from one of the objects in the
  //courseHwork array and append it there.
     $('.fc-day-number:contains("'+daysArray[i]+'")').append("&lt;div class='assignment'&gt;"+courseHwork[i].title+"&lt;/div&gt;&lt;br /&gt;");
          }
          }
  </code></pre>
  
  <p>If things worked as planned it will have found a div, that contains the string "4" and appended that property 'title' from the matching object in the courseHwork array.</p>
  
  <p>note: my actual daysArray covers numbers as strings "1"-"31", and the courseHwork array of objects is dynamically populated so it can contain any number of objects, however no object will have a property value that exceeds "31" in the substring being found.</p>
  
  <p>*<strong><em>QUESTION:</strong>
  How can I loop through two arrays and each time that matching values are found between the two arrays, an html element is found that also contains that exact same value, then has something appended to it?</em>*</p>