ScanSkill

includes

The includes() method checks if the item exists in the string or not.

Syntax

string.includes(item)

Example

const randomString = 'Hello World!';

console.log(randomString.includes('Hello')); // Prints: true

console.log(randomString.includes('o')); // Prints: true

console.log(randomString.includes('.')); // Prints: false

The includes() checks if the item exists character by character, if it does then it returns true, else it returns false.