Avatar ·

How to check if a string contains a substring in JavaScript? (includes, indexOf, search methods)

Hello everyone! I'm a beginner in JavaScript and I've encountered a task: I need to check if a certain word or phrase is inside a string. For example, I have a variable `let text = "Привет, мир! Сегодня отличная погода.";` and I want to know if this string contains the word "мир". \n\nI've tried several approaches, but they don't work as I expected. I tried simple comparison using `==` — but this compares the entire string, not searching for a substring. Then I found the `indexOf` method, but it returns a number, not true/false, and I'm not sure how to use it correctly for checking. \n\nHere's an example of my code that doesn't give the desired result:\n\n```javascript\nlet text = "Привет, мир! Сегодня отличная погода.";\nlet searchWord = "мир";\n\nif (text == searchWord) {\n console.log("The string contains