string.endsWith()

Test if a String ends with a provided suffix.

Signature

endsWith(suffix: String) => Boolean

Description

Tests if the calling String ends with a provided suffix. An exact match returns true. Otherwise, the method returns false.

Parameters

Parameter Type Required Description

suffix

String

true

Suffix to compare to the end of the calling String.

Return value

Type Description

Boolean

If true, the calling String ends with the suffix. Otherwise, false.

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
\