hasClosing()

Wrap.hasClosing()

Checks whether the text has given closing chars at the end.

wrap.class.ts
public static hasClosing(text: string, closing: string): boolean {
  return (
    typeof text === 'string' &&
    text.length >= 1 &&
    typeof closing === 'string' &&
    closing.length >= 1 &&
    text.slice(-closing.length) === closing
  );
}

Parameters

text: string

The text of string type, to check whether it contains given closing chars.

closing: string

The closing chars of string type to check if a given text contains.

Returns

The return value is a boolean indicating whether the text contains closing chars at the end.

Example usage

Last updated

Was this helpful?