• + 0 comments

    my simple javascript code, dont be overengineering

    function getTotalX(a, b) {
        // Write your code here
        let count = 0
        
        for (let i=a[a.length - 1];i<=b[0];i++) {
            const isFactorB = b.every(v => v % i === 0)
            const isAFactor = a.every(v => i % v === 0)
            
            if (isFactorB && isAFactor) {
                count++
            }
        }
        
        return count
    }