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

    Parameters

    • func: Function

      the function to be repeated

    Returns Function

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

    Example

    const plusTwo = twice(x => x + 1);
    plusTwo(2); // Returns 4