[Solved] Javascript accessing nested properties of an object literal
The line el.setAttribute(key, [key]); tries to set the attribute to an array containing the key as its only entry (and thus will set href to “href” since the array will get coerced to string). You probably meant el.setAttribute(key, obj.att[key]); // ——————^^^^^^^ Live Example: function hoistNav() { const nav = []; nav[0] = {text: ‘HOME’, att: … Read more