Say I have an object
called "groups", in it there are keys whose values are arrays:
let groups = {
group1: ['A', 'B', 'C'],
group2: ['X', 'Y', 'Z']
};
let item = 'B';
How would I go about finding out that the item
is in fact in group1
? (Note: There would be a lot of groups. I'm aware I could use a for
loop to iterate over each of the keys in the object. But would there be a faster way?)
via Wright
No comments:
Post a Comment