title: going through substr with loop and then want to identify the index
body: <p>Im trying to get the index number of corresponding characters in a string.
  I mean a loop does make it possible to treat characters in a string like an 'array' of characters with the string method <code>charAt()</code> and <code>indexOf()</code>, right?</p>
  
  <p>here's the code:</p>
  
  <pre><code>/** ****** WINDOW ONLOAD EVENT HANDLER **************** */
  window.onload = function(){
      // DOM elements
      var theButton = document.getElementById('theButton');
      var form = document.formISBN;
      var numberField = document.getElementById('theInput')
  
      theButton.onclick = function(){
          var number = numberField.value;
          console.log(number)
          controlNr = calculControlNr(number);
          // console.log(controlNr);
      }
  }
  
  function calculControlNr(number) {
      number = number.replace(' ','','g');
      number = number.replace('-','','g');
      var sum = 0;
      var sumEven = 0;
      var sumUneven = 0;
      var factor = 3;
      var numberExtract = number.substr(0,11);
  
      console.log(numberExtract.length)
      for (var i = 0; i &lt; numberExtract.length; i++) {
          console.log(numberExtract.indexOf(numberExtract.charAt(i)));
      }
  }
  </code></pre>