← Back to challenges

Check Factors

JavaScriptHardarraysvalidationloops

Instructions

Write a function that returns true if all integers in an array are factors of a number, and false otherwise.

Examples

checkFactors([2, 3, 4], 12) ➞ true
// Since 2, 3, and 4 are all factors of 12.

checkFactors([1, 2, 3, 8], 12) ➞ false
// 8 is not a factor of 12.

checkFactors([1, 2, 50], 100) ➞ true

checkFactors([3, 6], 9) ➞ false

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: FizzBuzz Interview Question