Source Academy Modules
    Preparing search index...

    Function thrice

    • Returns a new function which when applied to an argument, has the same effect as applying the specified function to the same argument 3 times.

      Parameters

      • func: Function

        the function to be repeated

      Returns Function

      the new function that has the same effect as (x => func(func(func(x))))

      const plusNine = thrice(x => x + 3);
      plusNine(0); // Returns 9