← Back to challenges

All Numbers in Array Are Prime

JavaScriptHardvalidationmatharrays

Instructions

Create a function that takes an array of integers and returns true if every number is prime. Otherwise, return false.

Examples

allPrime([7, 5, 2, 4, 6]) ➞ false

allPrime([2, 3, 5, 7, 13, 17, 19, 23, 29]) ➞ true

allPrime([1, 5, 3]) ➞ false

Notes

1 is not a prime number.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Potential Friend?