JS Built-ins
StringString.prototype.includesbeginner

String.prototype.includes() β€” empty string always returns true

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

Use includes() to check if a string contains a specific substring, with an optional start position.

String.prototype.includes() β€” Empty Substring

Every string includes the empty string ''.

Challenge: Implement alwaysTrue(str) that returns str.includes('').

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