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

    Parameters

    • func: Function

      the function to be repeated

    • n: number

      the number of times to repeat the function

    Returns Function

    the new function that has the same effect as func repeated n times

    Example

    const plusTen = repeat(x => x + 2, 5);
    plusTen(0); // Returns 10