JS Built-ins
StringString.prototype.endsWithbeginner

String.prototype.endsWith() β€” basic match

πŸ“– Usage Example
const str = 'Hello, World!'
str.endsWith('!')        // β†’ true
str.endsWith('World')    // β†’ false
str.endsWith('World', 12) // β†’ true

Use endsWith() to check if a string ends with a specific suffix, with an optional end position.

String.prototype.endsWith()

str.endsWith(searchString) returns true if the string ends with the given suffix.

Challenge: Implement endsWithPeriod(str) that returns true when str ends with '.'.

endsWithPeriod('Hello.') // β†’ true
endsWithPeriod('Hello!')  // β†’ false
πŸ’‘ Hints (1)
  • β€’ `.endsWith()` only checks the very end of the string.