title: BOOLEAN not working after adding FOR LOOP JavaScript
body: <p>I'm working on an assignment where a boolean has to switch after a variable is matched to a value in an array. The variable has to be matched with the value in the array using a <code>for</code> loop. However, I'm able to switch the boolean before I introduce the <code>for</code> loop. But after I introduce the <code>for</code> loop, the boolean is stuck to its original value of <code>false</code>.</p>
  
  <p>Can somebody explain why this is happening?</p>
  
  <p>Can I also request, I'm not looking for 'how to do this' but rather an explanation as to why is it happening - so I will appreciate if you do not recommend to me 'another better way' of achieving this - I just want to understand the concept as I'm a beginner.</p>
  
  <p>The code I'm using before the <code>for</code> loop (which changes the boolean correctly) is:</p>
  
  <pre><code>var c = 3;
  var w = [];
  var m = false;
  
  w.push(3,4);
  
  if (c === w[0]){
    m = true;
  }
  
  alert (m);
  </code></pre>
  
  <p>However after I add the <code>for</code> loop counter and also change the <code>if</code> condition from <code>c===w[0]</code> to <code>c===w[i]</code>, I only get the 'false' alert using the below code:</p>
  
  <pre><code>var c = 3;
  var w = [];
  var m = false;
  
  w.push(3,4);
  
  for (i=0; i&lt;2 &amp;&amp; c!==w[i]; i++){
    if (c === w[i]){
      m = true;
    }
  }
  
  alert (m);
  </code></pre>