• Just like array.reduce

    Example

    reduce('123', (prev, char) => prev + (+char), 0); // 6
    

    Type Parameters

    • T = any

    Parameters

    • str: string
    • fn: ((prev: T, char: string, index: number, chars: string[]) => T)
        • (prev: T, char: string, index: number, chars: string[]): T
        • Parameters

          • prev: T
          • char: string
          • index: number
          • chars: string[]

          Returns T

    • initialValue: T = ...

    Returns T

Generated using TypeDoc