check a in string code example
Example 1: check for substring javascript
const string = "javascript";
const substring = "script";
console.log(string.includes(substring)); //true
Example 2: how to check if a string contains a character
public static boolean containsIgnoreCase(String str, char c) {
str = str.toLowerCase();
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == Character.toLowerCase(c)) {
return true;
}
}
return false;
}