function getValue(objectValus, property) {
for(let prop in objectValus) {
if (prop === property) {
return objectValus[prop];
} else if (typeof(objectValus[prop]) === 'object') {
return getValue(objectValus[prop], property);
} else {
//return continue;
}
}
}
console.log(getValue({ a: { b: 5 }, c: { e: 4 }, g: 5 }, 'e'));
return getValue(objectValus[prop], property);
const getValue = (obj, key) => Object
.values(obj ?? {})
.reduce((found, n) => found ?? getValue(n, key), obj?.[key]);
function getValue(objectValus, property) {
for (let prop in objectValus) {
if (prop === property) {
if (typeof(objectValus[prop]) === 'object') {
return getValue(objectValus[prop], property);
}
return objectValus[prop];
}
}
return undefined;
}