I am trying to loop through a nested object, but I keep returning undefined.
My object:
var ltColumns = {
"col1": {data: "productCode", title: "Product Code", width: "7%" },
"col2": {data: "brand", title: "Brand", width: "5%"}
};
My loop:
for (var key in ltColumns) {
console.log(key.data);
}
In this case, I am trying to console log the "data" attribute of each nested object. However, I keep getting 'undefined'. Can someone help?
Thanks!