checking array of numbers (sequence) for missing values?
<p>I'm trying to create an array of a  list of numbers which are related to a bunch of documents. A bit like the following:</p>

<pre><code>var numArray = [0189459, 0189460, 0189461, 0189463, 0189465];
</code></pre>

<p>etc etc. The array will consist of a number sequence like the one above, say 0189400 - 0189500 my job is to find any missing numbers, as this sequence should be a consecutive sequence. Is there an easy way to do this or perhaps an Array function which can simplify this job? I've had a good look around and couldn't find anything specific.</p>

<p>The other thing i was thinking of trying but is a bit long winded is to find the lowest number in the sequence of document id's and highest number and create an array of consecutive numbers. then i can match this against an array of the actual numbers and log out the mismatches. But think this is a very longwinded way of tackling this.</p>

<p>Any thoughts?</p>

<p>UPDATE</p>

<p>Thanks for the help,</p>

<p>Sorry Kennebec couldn't get your function to work correctly in the end. See the comment below your answer. </p>

<p>Soufiane i solved it like you suggested</p>

<pre><code>var numArray = [0189459, 0189460, 0189461, 0189463, 0189465];
var mia= [];

    for(var i = 1; i &lt; numArray.length; i++) 
    {     
        if(numArray[i] - numArray[i-1] != 1) 
        {         
            var x = numArray[i] - numArray[i-1];
            var j = 1;
            while (j&lt;x)
            {
                mia.push(numArray[i-1]+j);
                j++;
            }
        }
    }
alert(mia) // returns [0189462, 0189464]
</code></pre>
