JS Built-ins
StringString.prototype.endsWithbeginner

String.prototype.endsWith() β€” empty string suffix

πŸ“– 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() β€” Empty Suffix

Every string ends with the empty string ''.

Challenge: Implement endsWithEmpty(str) that returns str.endsWith('').

endsWithEmpty('anything') // β†’ true
endsWithEmpty('')          // β†’ true
πŸ’‘ Hints (1)
  • β€’ The empty string is a suffix of every string.