Task of Challange #19
Create a function that will return in an array the first „nPrimes“ prime numbers greater than a particular number „startAt“
getPrimes has to accept two parameters.
nPrimes which decides the number of prime numbers we want to get out and
startAt which decides where we start to examine the prime numbers.
We create an empty
array and set our runningIndex
i equal to the
A while loop makes a continuous call to the
isPrime function and passes in the number we want to check. This is being done as long as our array is below the
So once we have the predestined number of primes, we will skip the while loop and return the array with prime numbers.
I have already explained the
isPrime function in Challenge #18.
For example if you call this function with
console.log(getPrimes(10, 100)); then the following picture is the output.