hasClosing()
Wrap.hasClosing()
Wrap.hasClosing()Checks whether the text has given closing chars at the end.
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
text: stringThe text of string type, to check whether it contains given closing chars.
closing: string
closing: stringThe 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?