I want to ask if I have an object like this
const dataArray = {
key1: ["a", "b"],
key2: ["c", "d"],
key3: ["e", "f"],
};
I tried
const obj = Object.keys(dataArray).map((data, index) => {
return dataArray[data];
if (dataArray[data].indexOf("water") > -1) {
return Object.keys(dataArray);
}
});
I want to return a key (key1, key2, key3) that has values of the string "c"
.
How do I do that? please help