title: How to loop through arrays of different lengths with JavaScript?
body: <p>The problem is best explained by the comments in my code.</p>
  
  <pre><code>// Find all commonNums divisible by arr &amp;&amp; sequential that produce a whole number quotient.
  // commonNums [ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]
  // arr [1,5]
  // sequential [ 2, 3, 4 ]
  for (var n = 0; n &lt; commonNums.length; n++) {
    for (var o = 0; o &lt; sequential.length; o++) {
      for (var p = 0; p &lt; arr.length; p++) {
    if (commonNums[n] % arr[p] === 0 &amp;&amp; commonNums[n] % sequential[o] === 0) {
    console.log(commonNums[n]);
  }}} 
  } 
  </code></pre>
  
  <p>Since the arrays are of different length, simply iterating through with one loop of length commonNums.length produced undefined values. My solution was to use 3 loops, one for each array.</p>
  
  <p>If common nums divided by arr has no remainder, and if common nums divided by sequential has no remainder, then return that number. For arr [1,5] the first number returned should be 60. </p>
  
  <p>Why does this solution fail?</p>