title: Javascript: How to compare to sentences word to word
body: <p>I'm sort of creating typing tutor with custom options. </p>
  
  <p>Not a professional (don't get mad at me for being wrong-person-wrong place) but thanks to helpful forums like stackoverflow.com and contributing traffic/people I'm able to pull it out in a day or two.</p>
  
  <p>Directly now, here!</p>
  
  <pre><code>    while (i &lt; len+1){
        if(boxarray[i] == orgarray[i]){
      ++i;
          actualScore = i - 1;
        }
  </code></pre>
  
  <p>I've searched already, '==' operator is of no use, I will not go for JSON.encode. I met similar solution at <a href="https://stackoverflow.com/questions/3746846/how-to-match-two-or-more-words">this page</a> . But in my case I've to loop through each word while comparing two sentences. Detail is trivial, if someone please help me solve above, I won't return with complain on the same project, promise. </p>
  
  <p>Okay I'm putting more code if it can help you help me.</p>
  
  <pre><code>    var paratext = document.getElementById('typethis').innerHTML;    
      var orgstr = "start typing, in : BtXr the yellow box but. please don't shit." ;
      var boxtext = document.getElementById('usit').value; 
      var endtrim = boxtext;
      var actualScore;
      var orgarray = listToArray(orgstr," ");
      var boxarray = listToArray(boxtext," ");
      var len = boxarray.length;
      var i = 0;
      var actualScore; //note var undefined that's one mistake I was making [edit]
      if(orgstr.indexOf(boxtext) !== -1){
      while (i &lt; len+1){
        if(boxarray[i] == orgarray[i]){
      ++i;
          actualScore = i - 1;
         }
       }      
      alert(actualScore);
      }
  </code></pre>