title: Use of string.length + counter variable
body: <p>I'm new to programming and am currently learning javascript on <a href="https://www.codecademy.com" rel="nofollow noreferrer">CodeAcademy</a>. This code below is from a tutorial where the program will search a string to look for a name. The program will loop through the array, compare each letter to the first letter of your name, and if it sees that letter:
  It will push that letter and all the letters that follow it to an array, stopping when the number of letters it pushes are equal to the number of letters in your name.</p>
  
  <p>What I don't understand is the line : <code>for (var j = i; j &lt; (myName.length + i); j++)</code>
  why does <code>j &lt;(myName.length + i)</code> and not <code>j&lt;(myName.length)</code>? If the letter "E" of "Eric" is the 25th character in the string, wouldn't <code>j&lt;(myName.length + i) = j&lt;("4" + "25")</code> which is wrong as it the correct code should be <code>j&lt;("4")</code> where 4 is the length of the name Eric.</p>
  
  <p>I've tried running the code with <code>j&lt;(myName.length)</code> but it fails to work and I cant seem to understand why.</p>
  
  <pre><code>text = "Blah blah blah blah blah blah Eric \
          blah blah blah Eric blah blah Eric blah blah \
          blah blah blah blah blah Eric";
  
  var myName = "Eric";
  var hits = [];
  
  // Look for "E" in the text
  for(var i = 0; i &lt; text.length; i++) {
      if (text[i] == "E") {
          // If we find it, add characters up to the length of my name to the array
          for(var j = i; j &lt; (myName.length + i); j++) {
              hits.push(text[j]);
          }
      }
  }
  
  if (hits.length === 0) {
      console.log("Your name wasn't found!");
  } else {
      console.log(hits);
  }
  </code></pre>