Question: I wrote this function that generates prime numbers for a given range of numbers, I think it's simple and clear that must give the expected result, though, there are numbers that are excluded from the result:

```js
function numberator(from, to) {
    numbers = [];
    for (x = from; x <= to; x++) {
        numbers.push(x);
    }
    return numbers;
}

function primeNumbers(array) {
    for (i = 0; i < array.length; i++) {
        for (j = 2; j < array[i]; j++) {
            if (array[i] % j == 0) {
                array.splice(i, 1);
            }
        }
    }
    return array;
}

console.log(primeNumbers(numberator(1,100)));
```

The result contains: 27, 35 and 95 (also 1, that I may handle later.)

I tried to figure out why but I couldn't.

Answer: 
The bug is in-place modification of **array** with splice. You keep on incrementing i, while the size of array is getting modified at execution time. 

You can debug this, by printing the whole array after each slice operation.

Also the solution is highly inefficient and will perform terribly for slightly long ranges. Use [Sieve of Eratosthenes](http://www.geeksforgeeks.org/sieve-of-eratosthenes/)
Take it more simple : 

```
const isPrime = (n =>
        n>1 && 
        Array.from({length: Math.floor(Math.sqrt(n))-1},(e,i) => i+2)
             .every(m => n%m)
);

const generateRange = (from, to) => Array.from({length: to-from + 1}, (v, k) => k+from);

```

then 

```
generateRange(1, 100).filter(isPrime); // DONE!

```

```js
//---- Utilities 
const isPrime = (n =>
        n>1 && 
        Array.from({length: Math.floor(Math.sqrt(n))-1},(e,i) => i+2)
             .every(m => n%m)
);

 const generateRange = (from, to) => Array.from({length: to-from + 1}, (v, k) => k+from);

//---------Apply ---
const from = 1;
const to = 100; 

 console.log (
    `Prime numbers from ${from} to ${to} are : `,
    generateRange(from, to).filter(isPrime)
  )
```