I want something like string.includes it can detect character among string but array.includes("a") can only detect if array[0] = "a" and return false when array[0] = "ab"
Is there anyway i can achieve string.includes in array without function and loop (1 line code) ? Thanks
var array = ["a", "b"];
array.includes("a"); //return true
var array = ["ab","b"];
array.includes("a"); //return false
Var string = "ab";
string.includes("a"); //return true
I want string.includes working with array without function and loop
>Solution :
Note that the join variant below will cause problems if the string match itself contains a comma.
const array = ['ab', 'cd']
console.log(array.some(i=>i.includes('a')))
// or
console.log(array.join().includes('a'))