I know the question is hard to understand so I will explain how I want it to be I have this array of data:
const products = [
{
name: "Product A",
reviews: [
{
comment: "Good Product",
username: "Alif",
},
],
},
{
name: "Product B",
reviews: [
{
comment: "Bad Product",
username: "Alif",
},
{
comment: "Good Product",
username: "Atif",
},
{
comment: "Ok Product",
username: "Esha",
},
],
},
];
products.map(({ reviews }) => {
console.log(reviews.length);
});
I would like to get the length of the reviews but since both objects are separate which is the Product A and the Product B, I get separated length or count like this:
I would please like the result to be total length of 4 or count of 4, so I thought of merging the array. Are there any other methods to be done?
