EN
JavaScript - check if string includes a character
0 points
In this article, we would like to show you how to check if a string includes a character in JavaScript.
Quick solution:
xxxxxxxxxx
1
'dirask is awesome!'.includes('d'); // true
In the below examples we check if the string
contains a character using includes()
method.
xxxxxxxxxx
1
const string = 'dirask is awesome!';
2
3
console.log(string.includes('d'));
xxxxxxxxxx
1
const string = 'dirask is awesome!';
2
3
console.log(string.includes('x'));