title: Why is Vanilla JS not running my if statement?
body: <p>So I'm making an Interchange game.</p>
  <p>I want the player to enter an answer and my if statements will check if that answer is correct, according to an array that I have set up. It will randomize so I will use the variable that is randomized to do something like this:</p>
  <pre><code>function getRandomImage(){
      var num = Math.floor(Math.random() * 10);
      var img = imageArray[num];
      document.getElementById(&quot;question-image&quot;).innerHTML = ('&lt;img src=&quot;' + img + '&quot;width=450px; height=550px; margin-left: auto; margin-right: auto;&quot;&gt;');
      console.log(&quot;random image!&quot;);
      console.log(answers[num]);
      const textarea = document.getElementById(&quot;answer-textarea&quot;).value;
  
      if (document.getElementById(&quot;answer-textarea&quot;).value == answers[num].toString() &amp;&amp; skipCounter &gt; 3){
          console.log(answers[num]);
          score++;
          document.getElementById(&quot;score-txt&quot;).innerHTML = (&quot;&lt;b&gt;Score: &lt;/b&gt;&quot; + &quot;&lt;b&gt;&quot; + score + &quot;&lt;/b&gt;&quot;);
      }
  
      else if (document.getElementById(&quot;answer-textarea&quot;).value != answers[num].toString() &amp;&amp; skipCounter &gt; 3){
          console.log(answers[num]);
          score--;
          document.getElementById(&quot;score-txt&quot;).innerHTML = (&quot;&lt;b&gt;Score: &lt;/b&gt;&quot; + &quot;&lt;b&gt;&quot; + score + &quot;&lt;/b&gt;&quot;);
      }
  }
  </code></pre>
  <p>HTML:</p>
  <pre><code>&lt;textarea class=&quot;answer-textarea&quot; id=&quot;answer-textarea&quot;&gt;&lt;/textarea&gt;
  </code></pre>
  <p>When I run this, AND I enter the correct answer according to my array, it does nothing.<a href="https://i.stack.imgur.com/ZgEEk.png" rel="nofollow noreferrer">1</a></p>
  <p>Array:</p>
  <pre><code>answers = new Array();
  answers[0] = &quot;Turbine Interchange&quot;;
  answers[1] = &quot;Complex Roundabout&quot;;
  answers[2] = &quot;Cloverleaf Interchange&quot;;
  answers[3] = &quot;High Five&quot;;
  answers[4] = &quot;Mixing Bowl Interchange&quot;;
  answers[5] = &quot;Light Horse Interchange&quot;;
  answers[6] = &quot;T Interchange&quot;;
  answers[7] = &quot;Trumpet Interchange&quot;;
  answers[8] = &quot;Vaanplein Junction&quot;;
  answers[9] = &quot;Ya'an East Road Interchange&quot;;
  </code></pre>
  <p>Is there something wrong with my code?</p>
  <p><strong>EDIT 1:</strong>
  I've updated my code now and I'm checking for my texrarea value, answer, skip counter and current score.</p>
  <pre><code>console.log(textarea + &quot;\n&quot; + answers[num] + &quot;\n&quot; + skipCounter + &quot;\n&quot; + score);
  </code></pre>
  <p><strong>EDIT 2:</strong>
  Yep the if functions are not even working. I added a new statement on the bottom of my ifs:</p>
  <pre><code>else {
      console.log(&quot;Did nothing!&quot;)
  }
  </code></pre>
  <p>It all just says &quot;did nothing&quot;.</p>