I would love to know why this code is failing some tests. It is intentionally not using any ES6 code.
Here is the prompt:
*A factor chain is an array where each previous element is a factor of the next consecutive element. The following is a factor chain:
[3, 6, 12, 36]
// 3 is a factor of 6
// 6 is a factor of 12
// 12 is a factor of 36
Create a function that determines whether or not an array is a factor chain.*
My code:
function factorChain(arr) {
var isChain = true;
for (var i = 0; i < arr.length; i++) {
if ((arr[i + 1] / arr[i]) !== Math.floor(arr[i + 1] / arr[i])) {
isChain = false;
}
}
return isChain;
}