JS Built-ins
StringString.prototype.includesbeginner

String.prototype.includes() β€” substring found

πŸ“– 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()

str.includes(searchString) returns true if the string contains the given substring.

Challenge: Implement containsHello(str) that checks if 'hello' is in str.

containsHello('say hello world') // β†’ true
containsHello('goodbye world')   // β†’ false
πŸ’‘ Hints (1)
  • β€’ `.includes()` returns a boolean β€” no need to check index.