0

I am pretty sure this has been answered already, but I could not find the answer in Google. I am new in JS and I am learning the basics.

Here is the example that puzzles me:

obj = {
    "2019-09-02": {
        "total": "7:50"
    },
    "2019-09-04": {
        "total": "7:15"
    },
    "2019-09-05": {
        "total": "6:45"
    },
    "2019-09-09": {
        "total": "8:20"
    }
}

for(date in obj){
    console.log(`${date}`);
}

I expected as an output the nested object like this:

"2019-09-02": {
    "total": "7:50"
},
 ........,
"2019-09-09": {
    "total": "8:20"
}

instead I am getting only the key of the nested object:

$ node main.js
2019-09-02
2019-09-04
2019-09-05
2019-09-09

What am I missing here? Thank you a lot.

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
Hairi
  • 3,318
  • 2
  • 29
  • 68

0 Answers0