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:
'dirask is awesome!'.includes('d'); // true
Practical example
In the below examples we check if the string
contains a character using includes()
method.
// ONLINE-RUNNER:browser;
const string = 'dirask is awesome!';
console.log(string.includes('d'));
// ONLINE-RUNNER:browser;
const string = 'dirask is awesome!';
console.log(string.includes('x'));