title: Generating <td> by 2 for loops by comparing 2 JavaScript arrays
body: <p>I want the my data table like in screenshot 1. But generating it by 2 for loops creating data table in screenshot 2.</p>
  
  <p><a href="https://i.stack.imgur.com/sHcRo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sHcRo.png" alt="screenshot 1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/CKVbk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CKVbk.png" alt="screenshot 2"></a></p>
  
  <p>my code:</p>
  
  <pre><code>for (a = 0; a &lt; sem_course_code.length; a++) {
  for (c = 0; c &lt; applied_courses.length; c++) {
      if (sem_course_code[a] == applied_courses[c]) {
          td_content += "&lt;td&gt;" + applied_courses[c] + "&lt;/td&gt;";
          continue;
      } else {
          td_content += "&lt;td&gt;--&lt;/td&gt;";
      }
  
    }
  }
  alert(td_content);
  $('#exam_marks_tbl tr:last').append(td_content);
  </code></pre>
  
  <p>Please help.</p>
  
  <p>Edit:
  for Number 1 student arrays are as below:</p>
  
  <pre><code>sem_course_code = [CRS02,CRS04,CRS03,CRS01];
  applied_courses = [CRS02,CRS01];
  </code></pre>