find a string in an array javascript
var myarr = ["I", "like", "turtles"];
var arraycontainsturtles = (myarr.indexOf("turtles") > -1);function checkInput(input, words) {
return words.some(word => input.toLowerCase().includes(word.toLowerCase()));
}
console.log(checkInput('"Definitely," he said in a matter-of-fact tone.',
["matter", "definitely"]));function checkInput(input, words) {
return words.some(word => new RegExp(word, "i").test(input));
}
console.log(checkInput('"Definitely," he said in a matter-of-fact tone.',
["matter", "definitely"]));
Also in JavaScript:
- document ready js
- strapi cloudinary how to use
- detect browser javascript
- make page refresh on top in react js
- routerlink for button in angular 7
- delete local storage javascript
- javascript get data-id attribute
- loop in javascript
- javascript Compare two arrays regardless of order
- Javascript remove last character
- trigger play video jquery
- s3 bucket as static website for angular
- Unexpected token 'export'
- javascript random()
- canvas event listener js
- java script methode
- jquery cheat sheet
- settimeout in react
- js get element type
- js import and export
- how to remove an item from an array in javascript
- nodejs map
- javascript progress of xml http request
- javascript date calculations ignore weekends