To check if a string contains a specific character in JavaScript, you can use the 'includes' method of the String class.
In this example,
function containsCharacter(str, ch) {
return str.includes(ch);
}
let str = 'Hello World';
let ch = 'W';
let contains = containsCharacter(str, ch);
console.log(`String contains character '${ch}': ${contains}`);
String contains character 'W': true
In this tutorial, we learned How to Check if String contains specific Character in JavaScript language with well detailed examples.