check if string contains character javascript
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)var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
alert("Not again");
}
Also in JavaScript:
- javascript format price
- timestamp to unix time react
- component unmount useeffect
- dropdown validation using jquery
- '@babel/plugin-proposal-class-properties' webpack
- angular attach component to body
- expressjs swagger yaml
- javascript convert int to float with 2 decimal places
- how to make a show password button
- javascript merge two array with spread operator
- how to connect react to backend
- export default
- check if not checked vanila js
- javascript execute function by string name
- javascript var vs let
- textinput onpress react native
- localStorage
- filter geojson programmatically
- javascript try catch finally
- simulate a user click
- v-switch vuex store
- jquery number format comma
- asynchronous javascript
- Redux