Functional programming FizzBuzz I tried to code the fizzbuzz program following the functional programming rules in javascript. Please check my code and give feedback. thank you.
const isDivisible = (number, fizz) =&gt; number % fizz === 0;
const getSubstitutes = (
  number,
  substitutes,
  { currentIndex = 0, result = &quot;&quot; } = {}
) =&gt; {
  if (currentIndex === substitutes.length) return result;
  const { divisor, substitute } = substitutes[currentIndex];
  const newResult = result + (isDivisible(number, divisor) ? substitute : &quot;&quot;);
  return getSubstitutes(number, substitutes, {
        currentIndex: currentIndex + 1,
        result: newResult,
  });
};
const fizzBuzz = (number, substitutes, currentIndex = 1) =&gt; {
  if (number &lt; currentIndex) return;
  console.log(getSubstitutes(currentIndex, substitutes) || currentIndex);
  fizzBuzz(number, substitutes, ++currentIndex);
};
const substitutes = [
  {
        divisor: 3,
        substitute: &quot;fizz&quot;,
  },
  {
        divisor: 5,
        substitute: &quot;buzz&quot;,
  },
];
fizzBuzz(100, substitutes);
Overall it looks like you're missing out on most of the benefits of a functional approach and over-complicating your code. First glance it's basically impossible to work out what it's all doing without following each variable through everything.
Per the previous answer you don't seem familiar with common functional techniques like using .map, pipelines, or avoiding side-effects
Below is less a review of your code but a different solution that highlights the  techniques you're missing so you can see them in action
const fizzOrBuzz = (a, b, aPhrase, bPhrase) =&gt; (
    (n) =&gt; (
        (n % (a*b) === 0) ? aPhrase + bPhrase :
        (n % a === 0) ? aPhrase :
        (n % b === 0) ? bPhrase :
        n
    )
)

const generateNLengthArray = (n) =&gt; [ ...Array(n).keys()].map(i =&gt; i + 1)

const mapArrayTo = (f) =&gt; (array) =&gt; array.map(i =&gt; f(i)) 

const joinArray = (array) =&gt; array.join('\n')

const pipe = (...fns) =&gt; (x) =&gt; fns.reduce((v, f) =&gt; f(v), x) // One-liner pipeline pattern

const fizzbuzz = pipe(
    generateNLengthArray,
    mapArrayTo(fizzOrBuzz(3, 5, 'fizz', 'buzz')),
    joinArray
)

console.log(fizzbuzz(100))

One of the benefits of functional programming is breaking everything down into discrete, easily understandable functions, and then composing them together so it's crystal clear what's happening.
In this case defining fizzbuzz as a pipeline of three separate functions makes it clear that you're 1. creating an array of a specific length. 2. mapping the values of that array to either fizz or buzz and 3. joining the results together