title: If clauses in for loop acts weird
body: <p>I have a function, which collects inputted answer and checked if collected answer is the same as it is the solution. Questions are asked randomly. Questions and solutions are in separate .txt file.</p>
  
  <p>I have a file with some words and the program always fulfil its condition if the last word from the list is correctly answered, even though if other answers from other questions are correct. </p>
  
  <p>Any suggestions?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var besedeNemske = ["glava", "voda", "drevo"];
  var besedePrevod = ["der Kopf", "das Wasser", "der Baum"];
  
  
  window.onload = function() {
    var fileInput = document.getElementById('fileInput');
    var fileDisplayArea = document.getElementById('fileDisplayArea');
  
    fileInput.addEventListener('change', function(e) {
      var file = fileInput.files[0];
      var textType = /text.*/;
  
      if (file.type.match(textType)) {
        var reader = new FileReader();
  
        reader.onload = function(e) {
  
          var lines = this.result.split('\n');
          for (var line = 0; line &lt; lines.length; line++) {
            if (line % 2 != 0) {
              besedeNemske.push(lines[line]);
            } else {
              besedePrevod.push(lines[line]);
            }
          }
  
        }
  
        reader.readAsText(file);
      } else {
        fileDisplayArea.innerText = "File not supported!"
      }
    });
  }
  
  
  
  var random = 0;
  
  function nastaviRandom() {
    random = Math.floor(Math.random() * 5);
  }
  
  function noviGlagol() {
  
    nastaviRandom();
  
    document.getElementById("vprasanje").innerHTML = besedePrevod[random];
  
  }
  
  function preveriOdgovor() {
    var odgovorjeno = document.getElementById("mojOdgovor").value;
    if (besedeNemske.indexOf(odgovorjeno) == random) {
      document.getElementById("odgovor").innerHTML = "Pravilni odgovor";
    } else {
      document.getElementById("odgovor").innerHTML = "Napačen odgovor.   Pravilni odgovor je " + (besedeNemske[random]) + "";
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div id="page-wrapper"&gt;
  
      &lt;h1&gt;Nemščina glagoli&lt;/h1&gt;
      &lt;div&gt;
        Select a text file:
        &lt;input type="file" id="fileInput"&gt;
      &lt;/div&gt;
      &lt;pre id="fileDisplayArea"&gt;&lt;pre&gt;
  
          &lt;button onclick="noviGlagol()"&gt;Novi glagol&lt;/button&gt;
  
          &lt;div id="vprasanje"&gt;&lt;/div&gt;
          &lt;div id="odgovor"&gt;&lt;/div&gt;
  
          &lt;input type="text" id="mojOdgovor"&gt;
          &lt;button onclick="preveriOdgovor()"&gt;Pošlji&lt;/button&gt;
  &lt;/div&gt;
  &lt;script&gt;
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;html&gt;</code></pre>
  </div>
  </div>
  </p>