Recursive
by Dima Polos
HTML
<div id="res">
</div>
CSS
#res {
font-size: 30px;
}
JavaScript
let obj = {
a: {
b: {
c: {
res: 'Hello!',
}
}
}
};
function search(el, obj) {
return obj[el];
}
let arr = ['a', 'b', 'c', 'res'];
for (let el of arr) {
obj = search(el, obj);
}
document.getElementById('res').innerHTML = obj;