Answer the question
In order to leave comments, you need to log in
How to solve the problem in tree traversal (does not store value)?
function queryString(obj, nodePath, hist) {
nodePath = nodePath || '';
hist = hist || '';
Object.keys(obj).forEach(k => {
if (typeof obj[k] == 'object' && obj[k] !== null) {
// console.log('obj', k);
nodePath += '{}==' + k;
queryString(obj[k], nodePath, hist);
} else {
hist += nodePath;
hist += '{}!=' + k;
}
});
return hist;
}
{
a: {
b: {
c: {
e: 'hello'
},
d: 'aloha'
}
}
}
'{}==a{}==b{}==c{}!=e' + '{}==a{}==b{}!=d' // разделил для удобочитаемости
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question