title: Comparing two strings for identical values
body: <pre><code>// Write a program to check whether or not two arrays are identical in size, and hold identical values
  
  string1 = prompt("String 1?");
  string2 = prompt("String 2?");
  
  compareNum = 0;
  
  for(i=0; i&lt;string1.length; i++)
  {
      for(j=i; j&lt;string2.length; j++)
      {
      if (string1.charAt(i) == string2.charAt(j))
  {
          compareNum++;
          break;
  }
      }
  };
  
  alert("We found " + compareNum + " identical value(s).");
  </code></pre>
  
  <p>I've managed to build a relatively simple string comparison program but now the problem I have is the result it outputs. </p>
  
  <p>For example if I type in "Jeansy" and "Jeansy" - I get the response of "We found 6 identical values." </p>
  
  <p>Whereas if I type in "Molanza" and "Molanza" - I get the reply of "We found 9 identical values." </p>
  
  <p>Surely it should only be 7?</p>
  
  <p>Or does the 'a' get counted twice? Is there anyway I can negate this?</p>
  
  <p>Btw I'm taking into account all strings.</p>
  
  <p>Thanks in advance!</p>