Answers for "js check if string includes from array"

1

check if array does not contain string js

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"]));
Posted by: Guest on June-07-2020
3

javascript check if in array

var extensions = ["image/jpeg","image/png","image/gif"];          
if(extensions.indexOf("myfiletype") === -1){
	alert("Image must be .png, .jpg or .gif");
}
Posted by: Guest on January-13-2020
0

js check if string includes from array

function buildSearch(substrings) {
  return new RegExp(
    substrings
    .map(function (s) {return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');})
    .join('{1,}|') + '{1,}'
  );
}


var pattern = buildSearch(['hello','world']);

console.log(pattern.test('hello there'));
console.log(pattern.test('what a wonderful world'));
console.log(pattern.test('my name is ...'));
Posted by: Guest on October-14-2021
0

js check if array contains value

return arrValues.indexOf('Sam') > -1
Posted by: Guest on October-13-2021
0

js check if string includes from array

const found = arrayOfStrings.find(v => str.includes(v));
Posted by: Guest on October-13-2021
0

js check if string includes from array

wordsArray = ['hello', 'to', 'nice', 'day']
yourString = 'Hello. Today is a nice day'.toLowerCase()
result = wordsArray.every(w => yourString.includes(w))
console.log('result:', result)
Posted by: Guest on October-13-2021

Code answers related to "js check if string includes from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language