Hello Guys, I'm a newbie to javascript and i would like your help to solve this problem. I need to count the total of comment in this array. But the object in this array has different length of key pair. how do i looping through this array of object? Really appreciate any help, been stuck in this problem for hours.
const comments = [
{
commentId: 1,
commentContent: 'Hai',
replies: [
{
commentId: 11,
commentContent: 'Hai juga',
replies: [
{
commentId: 111,
commentContent: 'Haai juga hai jugaa'
},
{
commentId: 112,
commentContent: 'Haai juga hai jugaa'
}
]
},
{
commentId: 12,
commentContent: 'Hai juga',
replies: [
{
commentId: 121,
commentContent: 'Haai juga hai jugaa'
}
]
}
]
},
{
commentId: 2,
commentContent: 'Halooo'
}
]
Top comments (1)
update: one shot