const str = "Nice to meet you! Welcome to codingCourses.";

console.log(str.includes("codingCourses")); // Output: true
console.log(str.includes("CODINGCOURSES")); // Output: false (case-sensitive)
str.includes(searchString)
str.includes(searchString, position)
const haystack = "Hello, World!";
const needle = "world";

const isNeedle = haystack.includes(needle); // false (case-sensitive)

if (isNeedle) {
    console.log(`The string contains '${needle}'.`);
} else {
    console.log(`The string does not contain '${needle}'.`);
}

// Output: "The string does not contain 'world'."
const haystack = "Hello, World!";
const needle = /Hello/; // Must not be a regular expression. Throws a TypeError.

const isNeedle = haystack.includes(needle);

if (isNeedle) {
    console.log(`The string contains '${needle}'.`);
} else {
    console.log(`The string does not contain '${needle}'.`);
}
const haystack = "Welcome!";
const needle = "";

const isNeedle = haystack.includes(needle);

console.log(isNeedle); // An empty string always returns true.
const text = "I like apples and bananas.";
const searchTerm = "apples";

if (text.includes(searchTerm)) {
    console.log(`The text contains the word '${searchTerm}'.`);
} else {
    console.log(`The text does not contain the word '${searchTerm}'.`);
}

// Output: "The text contains the word 'apples'."
const content = "This sentence contains an unwanted word.";
const unwantedWords = ["unwanted", "bad", "inappropriate"];

unwantedWords.forEach(unwantedWord => {
    if (content.includes(unwantedWord)) {
        let filteredContent = content.replace(unwantedWord, "***");
        console.log(filteredContent);
    }
});

// Output: "This sentence contains an *** word."
// Find the string "hello" without case sensitivity
const searchStr = "hello";
const str = "Hello, world! hello, universe!".toLowerCase();

let count = 0;
let startIndex = 0;

while (str.includes(searchStr, startIndex)) {
    count++;
    startIndex = str.indexOf(searchStr, startIndex) + 1;
}

console.log("Number of occurrences:", count);
// Output: Number of occurrences: 2