string.endsWith()

Test whether the String ends with a given String.

Signature

endsWith(otherString: String) => Boolean

Description

The endsWith() method determines whether this String ends with otherString. An exact match returns true. Otherwise, the method returns false.

Parameters

Parameter Type Required Description

otherString

String

Yes

String to compare with the end of this String.

Return value

Type Description

Boolean

String comparison result:
true = Calling string ends with otherString.
false = Calling string doesn’t end with otherString.

Examples

  1. Test whether a String ends with 200 OK:

    "HTTP/1.1 200 OK".endsWith("200 OK")
    true
  2. Test whether a String ends with 200:

    "HTTP/1.1 200 OK".endsWith("200")
    false

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!