I am curious about the reasons why this code is failing some of the tests provided. It deliberately avoids using any ES6 code.
Here is the given prompt:
*A factor chain can be defined as an array where each preceding element serves as a factor for the subsequent element. An example of a factor chain is shown below:
[3, 6, 12, 36]
// 3 is a factor of 6
// 6 is a factor of 12
// 12 is a factor of 36
The task at hand is to create a function that can determine whether or not a given array constitutes a factor chain.*
The following snippet showcases my approach:
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;
}