I have the following data:
const temp = {
"_id" : "5def6486ff8d5a2b1e52fd5b",
"data" : {
"files" : [
{
"path" : "demo1.cpp",
"lines" : [
{
"line" : 18,
"count" : 0
}
]
},
{
"path" : "file2/demo2.cpp",
"lines" : [
{
"line" : 9,
"count" : 0
}
]
}
]
}
}
Now, I want to access the path
, and line
variable inside each of the files
. I am still learning using JS and pretty new with Object.keys.
I have this:
Object.keys(temp.data.files).forEach(file => console.log(file));
This simply prints 0 and 1. Where am I going wrong in this?