Working with String Search and Slice Methods - How Can You Test if a String Contains a Substring?

Tell us what’s happening:

let text = “Hello, JavaScript world!”;
let result = text.includes(“JavaScript”, 7);

console.log(result); // true

always returns true, the change of number makes no difference

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Working with String Search and Slice Methods - How Can You Test if a String Contains a Substring?

Welcome to the form @olga.murzha

let text = "Hello, JavaScript world!";
let result = text.includes("JavaScript", 8);

console.log(result) // false

The second parameter in the includesmethod is for the starting index.

Hello, Jav
0123456789

Any number above 7 will assign false to the resultvariable.

Happy coding