can I chain sort and filter js code example
Example 1: javascript factor chain
function factorChain(arr) {
for (let i = 0; i < arr.length - 1; i++) {
if ((arr[i + 1] % arr[i]))
return false
}
return true
}
Example 2: javascript factor chain
function factorChain(num) {
let n = num.slice(num.length - 1, num.length)[0]
return [...Array(n + 1).keys()]
.filter(v => n % v === 0)
.map((v, i) => v === num[i])[0]
}