Answers for "js how to check if a string contains a certian character"

2

how to check if a string contains a certain letter in js

// use the variable.includes() 
const myString = "hello world!"
if(myString.includes("hello")){
  // do something 
}else{
  //also do something
}
Posted by: Guest on April-24-2022
1

js check if string contains character

if (your_string.indexOf('hello') > -1)
{
  alert("hello found inside your_string");
}
Posted by: Guest on June-12-2020

Code answers related to "js how to check if a string contains a certian character"

Code answers related to "Javascript"

Browse Popular Code Answers by Language