title: Find Missing Numbers from Unsorted Array
body: <p>I found this JavaScript algorithm excercise:</p>
  
  <p><strong>Question</strong>:</p>
  
  <p>From a unsorted array of numbers 1 to 100 excluding one number, how will you find that number?</p>
  
  <p>The solution the author gives is:</p>
  
  <pre><code>function missingNumber(arr) {
      var n = arr.length + 1,
          sum = 0,
          expectedSum = n * (n + 1) / 2;
  
      for (var i = 0, len = arr.length; i &lt; len; i++) {
          sum += arr[i];
      }
  
      return expectedSum - sum;
  }
  </code></pre>
  
  <p>I wanted to try and make it so you can find multiple missing numbers.</p>
  
  <p>My solution:</p>
  
  <pre><code>var someArr = [2, 5, 3, 1, 4, 7, 10, 15]
  
  function findMissingNumbers(arr) {
      var missingNumbersCount;
      var missingNumbers = [];
      arr.sort(function(a, b) {
          return a - b;
      })  
      for(var i = 0; i &lt; arr.length; i++) {
          if(arr[i+1] - arr[i] != 1 &amp;&amp; arr[i+1] != undefined) {
              missingNumbersCount = arr[i+1] - arr[i] - 1;
              for(j = 1; j &lt;= missingNumbersCount; j++) {
                  missingNumbers.push(arr[i] + j)
              }
          }
      }
      return missingNumbers
  }
  
  findMissingNumbers(someArr) // [6, 8, 9, 11, 12, 13, 14]
  </code></pre>
  
  <p>Is there a better way to do this? It has to be <strong>JavaScript</strong>, since that's what I'm practising.</p>