title: Check if an array contains duplicate values
body: <p>I wanted to write a javascript function which checks if array contains duplicate values or not.</p>
  
  <p>I have written the following code but its giving answer as "true" always.</p>
  
  <p>Can anybody please tell me what am I missing.</p>
  
  <pre><code>function checkIfArrayIsUnique(myArray) 
      {
          for (var i = 0; i &lt; myArray.length; i++) 
          {
              for (var j = 0; j &lt; myArray.length; j++) 
              {
                  if (i != j) 
                  {
                      if (myArray[i] == myArray[j]) 
                      {
                          return true; // means there are duplicate values
                      }
                  }
              }
          }
          return false; // means there are no duplicate values.
      }
  </code></pre>