JS Built-ins
StringString.prototype.endsWithbeginner

String.prototype.endsWith() β€” case-sensitive

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

.endsWith() is case-sensitive: 'Hello'.endsWith('o') β†’ true but 'Hello'.endsWith('O') β†’ false.

Challenge: Implement endsWithO(str) that checks if str ends with lowercase 'o'.

endsWithO('hello') // β†’ true
endsWithO('hellO') // β†’ false
πŸ’‘ Hints (1)
  • β€’ `.endsWith()` performs a case-sensitive comparison.