I'm trying to get the object with the greatest number of elements and get the number of elements.
I currently have the following:
var array = [
[{
'id': 1,
'value': 100
}, {
'id': 1,
'value': 100
}],
[{
'id': 1,
'value': 100
}, {
'id': 1,
'value': 100
}, {
'id': 1,
'value': 100
}],
[{
'id': 1,
'value': 100
}, {
'id': 1,
'value': 100
}]
];
for (var i = 0; i < array.length; i++) {
console.log(array[i].length);
//Here I need to get the bigger number in this case is 3, because I need it to another validations inside this for loop
}
In this case I know what is the bigger object, but I need to get the number and save it in a variable because I need to do some validations after.
I hope that you can understand me and help me