Function strEnsureEndsWith

  • Ensures that a string ends with a specified substring. If the string already ends with the specified substring, it is returned as is. Otherwise, the substring is appended to the end of the string.

    Parameters

    • string: string

      The string to be processed.

    • endsWith: string

      The substring that the string should end with.

    Returns string

    Example

    strEnsureEndsWith('52', ' kg');
    //=> '52 kg'
    strEnsureEndsWith('52 kg', ' kg');
    //=> '52 kg'

Generated using TypeDoc