The original object can be iterated over and the length of each property value can be determined...
const comments ={
"a":[
{
"a":"b"
}],
"b":[
{
"a":"b"
},
{
"a":"b"
},
{
"a":"b"
},
{
"a":"b"
}] };
let count=1;
for(let key in comments)
{
console.log(`${count}. Length: ${comments[key].length}`);
count++;
}
You can use this approach without setting counter. I think the code is explaining itself, but if you need any further explanation i'm here to help.
const keys = Object.keys(comments);
keys.forEach((key, index) => {
console.log(`${index + 1}. Length: ${comments[key].length}`);
});