I was able to guess to fill in the blanks for this exercise, but really do not understand how this code creates a new array of only prime numbers. Thanks for your explanation in advance!

Complete the blanks to create a JavaScript array primes containing prime numbers only.

const numbers = [16, 6, 26, 5];
const primes = (p => {
return p-3;

So it returns 13, 3, 23 and 2. All prime numbers. It just takes three off each number in the array.

1 Like