Array.Include? Multiple Values

How to check whether multiple values exist within an Javascript array

function containsAll(needles, haystack){ 
for(var i = 0; i < needles.length; i++){
if($.inArray(needles[i], haystack) == -1) return false;
}
return true;
}

containsAll([34, 78, 89], [78, 67, 34, 99, 56, 89]); // true
containsAll([34, 78, 89], [78, 67, 99, 56, 89]); // false
containsAll([34, 78, 89], [78, 89]); // false

JavaScript - include() - A check to see if multiple elements are in an array

The issue is in your if statement because includes() returns a boolean based on the string parameter. A better way of doing this would be to use something like:

if(arr.includes("TL") && arr.includes("TM") && arr.includes("TR")) {
console.log("yes");
}

If you have lots of elements in your array I would suggest something more along the lines of:

var flag = true;
for(i=0; i<arr.length; i++) {
if(!arr.includes(arr[i])) {
flag = false;
}
}
if(flag) {
console.log("yes");
}

Array.include? multiple values

You could take the intersection of two arrays, and see if it's not empty:

([2, 6, 13, 99, 27] & [2, 6]).any?

multiple conditions for JavaScript .includes() method

That should work even if one, and only one of the conditions is true :

var str = "bonjour le monde vive le javascript";
var arr = ['bonjour','europe', 'c++'];

function contains(target, pattern){
var value = 0;
pattern.forEach(function(word){
value = value + target.includes(word);
});
return (value === 1)
}

console.log(contains(str, arr));

Multiple values inside array

Console.WriteLine(string.Join(",", array2.Reverse().Zip(array1, (a, b) => a*b)));

or

array3 = array2.Reverse().Zip(array1, (a, b) => a*b).ToArray();

check for multiple Array.includes using or

As the documentation the Array.includes can only test for a single element.

You could reverse your logic though and use

if (['slug-title-one','slug-title-13'].some(slug => item.slug.includes(slug))) {
// checks for and displays if either

}

How to check if an array has multiple values and push to a new array if a value is met?

You can loop through the items and tags, store the items to the specific arrays and finally update the state. Check the code below-

const data = [
{
id: 'xyz',
name: 'test',
tags: ["Mechanical", "Director", "Specialist"]
},
{
id: 'abc',
name: 'abc',
tags: ["Mechanical", "Specialist"]
}
];

const _mechanical = [];
const _director = [];
const _specialist = [];

for (const item of data) {
if (item?.tags?.length > 0) {
for (const tag of item.tags) {
switch(tag.toLowerCase()) {
case 'mechanical':
_mechanical.push(item);
break;
case 'director':
_director.push(item);
break;
case 'specialist':
_specialist.push(item);
break;
}
}
}
}

console.log(JSON.stringify(_mechanical));
console.log(JSON.stringify(_director));
console.log(JSON.stringify(_specialist));

searching multiple values in string array in javascript/react

You can use every and includes to utilize your logic