title: Push duplicate items into a separate array in Javascript with for loop?
body: <p>For some reason, the manipulated doubleArray below is not shown in the console. Any variables that I declare after the for loop won't show to the console on both cases. Consider that in the first algorithm, there is only one for loop with x being incremented everytime. Whereas, in the second algorithm, it's a nested for loop. Can someone help me fix my error in both algorithms?
  First Algorithm:</p>
  
  <pre><code>var isDuplicate = function() {
    var helloWorld = [1,2,3,4,3];
    var doubleValue = [];
    var x = 0;
    for (i = 0; i &lt; helloWorld.length; i++) {
      x = x + 1;
      if (helloWorld[i] === helloWorld[x] &amp;&amp; i !== x) {
        doubleValue.push(helloWorld[i])
        console.log(helloWorld[i]);
      } else {
        continue;
      }
    }
    console.log(doubleValue);
  };
  </code></pre>
  
  <p>The second Algorithm:</p>
  
  <pre><code>var isDuplicate = function() {
    var helloWorld = [1,2,3,4,3];
    var doubleValue = [];
    for (i = 0; i &lt; helloWorld.length; i++) {
      for (x = 1; x &lt; helloWorld.length; i++) {
        if (helloWorld[i] === helloWorld[x] &amp;&amp; i !== x) {
          doubleValue.push(helloWorld[x]);
        }
      }
    }
    console.log(doubleValue);
  };
  </code></pre>