Functional Implementation of Co-prime pairs in array
How is my choice of variable names?


In general you used snake case for the function names which is more a ruby-style.  

Additionally the function co_prime_pairs let me acept that it return pairs of co-primes. However it returns a number of co-pairs inside an array.  

The variable co_primes is declared globally.

co_prime_pairs

This function is not a pure function internally because .forEach(y =&gt; co_primes.push([x, y])) modifies co_primes.
I rewrite the function and spit the logic into:


build pairs
filter the co primes
return the length


The functions:

const filterCoPrimes = xss =&gt;
    xss.filter(xs =&gt; isCoPrime(xs[0], xs[1]))

const buildPair = x =&gt; y =&gt;
    [x, y]

const buildPairs = (xs, pairs) =&gt;
    xs.length === 0 || xs.length === 1
        ? pairs
        : buildPairs(
            xs.slice(1), 
            pairs.concat(xs.map(buildPair(xs[0])))
        )


The chain:

const co_prime_pairs = xs =&gt;
    filterCoPrimes(buildPairs(xs, [])).length


If we use pipe as a kind of function composition it can be rewritten to:

const co_prime_pairs = pipe(
    buildPairs([]),
    filterCoPrimes,
    length
)


Full working Example


function calls:




const gcd = (a, b) =&gt; 
  (b != 0) ? gcd(b, a % b) : a

const isCoPrime = (a, b) =&gt; 
  gcd(a, b) === 1

const filterCoPrimes = xss =&gt;
  xss.filter(xs =&gt; isCoPrime(xs[0], xs[1]))

const buildPair = x =&gt; y =&gt;
  [x, y]

const buildPairs = (xs, pairs) =&gt;
  xs.length === 0 || xs.length === 1
      ? pairs
      : buildPairs(
          xs.slice(1), 
          pairs.concat(xs.map(buildPair(xs[0])))
      )

const co_prime_pairs = xs =&gt;
  filterCoPrimes(buildPairs(xs, [])).length

console.log(co_prime_pairs([4, 8, 3, 9]))





with pipe:




const pipe = (...fns) =&gt; fns.reduce((f, g) =&gt; (...args) =&gt; g(f(...args)))

const filter = fn =&gt; xs =&gt;
    xs.filter(fn)

const map = fn =&gt; xs =&gt;
    xs.map(fn)

const length = xs =&gt; 
    xs.length

const gcd = (a, b) =&gt; 
    (b != 0) ? gcd(b, a % b) : a

const isCoPrime = (a, b) =&gt; 
    gcd(a, b) === 1

const filterCoPrimes = xss =&gt;
    xss.filter(xs =&gt; isCoPrime(xs[0], xs[1]))

const buildPair = x =&gt; y =&gt;
    [x, y]

const buildPairs = pairs =&gt; xs =&gt;
    xs.length === 0 || xs.length === 1
        ? pairs
        : buildPairs
            ( pairs.concat(xs.map(buildPair(xs[0]))) )
            ( xs.slice(1) )

const co_prime_pairs = pipe(
    buildPairs([]),
    filterCoPrimes,
    length
)
    
console.log(co_prime_pairs ([4, 8, 3, 9]))