I have two 3 unique arrays:
const a =["b","c","d"];
const b = ["ab","cd","ef"]
const c = ["abc", "cde","fgh"]
with array.includes("ab") we can findout that it is in b array. but If we take abc and want to search which arrayname it is present in?
How can I do that
Here's one way
const a =["b","c","d"];
const b = ["ab","cd","ef"]
const c = ["abc", "cde","fgh"]
const find = (needle, haystack) => Object.entries(haystack).find(([k,v])=>v.includes(needle))[0];
console.log(find('ab', {a, b, c}))
console.log(find('abc', {a, b, c}))
of course, this returns a string, which is almost useless to then access the array in a meaningful way - but this does answer the question