title: Why won't a simple Javascript if condition execute?
body: <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;button onClick="Display()"&gt;&lt;/button&gt;
  
  &lt;script&gt;
  function Display() {
      var a = 0;
      if(a = 0){
        alert("hello world");
      }
  } 
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I run the page and clicked the button and nothing happens.  I can't for the life of me figure out why...</p>
  
  <p>Edit: on another note, THIS code executes no matter what, even if I haven't defined var CorrectActivities:</p>
  
  <pre><code>function Display() {
  
      if(CorrectActivities = 3) {
          document.getElementById("ActivitiesResult").innerHTML = '&lt;span&gt;style="color:DarkGreen;font-weight:bold;font-size:30px;"&gt;3 out of 3 correct!&lt;/span&gt;';
  
      } else if (CorrectActivities = 2) {
          document.getElementById("ActivitiesResult").innerHTML = '&lt;span style="color:Crimson;font-weight:bold;font-size:30px;"&gt;2 out of 3 correct!&lt;/span&gt;';
  
      } else if (CorrectActivities = 1) {
          document.getElementById("ActivitiesResult").innerHTML = '&lt;span style="color:Crimson;font-weight:bold;font-size:30px;"&gt;1 out of 3 correct!&lt;/span&gt;';
  
      } else {
      document.getElementById("ActivitiesResult").innerHTML = '&lt;span style="color:Crimson;font-weight:bold;font-size:30px;"&gt;0 out of 3 correct!&lt;/span&gt;';
      }
  }
  </code></pre>
  
  <p>Edit2: thanks for the answers.  First code is fixed, second is still broken regardless of what I try.  Going to look for errors elsewhere in the script...</p>