What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-06 21:00:04
javascript check if string contains at the begins with substring
var str = "We got a poop cleanup on isle 4."; if(str.indexOf("poop") !== -1){ alert("Not again"); } //use indexOf (it returns position of substring or -1 if not found) Add solution