So I can see the problem, I just don't know how to fix it. I've been all over the interwebz!
I don't know how you're supposed to move to the next entry in the object tree when the condition doesn't match. At the moment I'm just overloading the call stack.
const myObject = {
x: {
y: {
z: {
e: 'ddfg'
}
}
}
};
const param = Object.keys(myObject);
function traverse(target) {
for (const key in target) {
if (target[key] !== 'e') {
traverse(target[key]);
} else {
console.log(key, target[key]);
}
}
}
traverse(param);
If you could lend a hand that would be great!