Currently, I'm incorporating lodash.js into my project but it seems that there is no built-in method to achieve what I need. Even after attempting it on my own, I find myself dissatisfied with the outcome.
function findLargestArrayInObject(object) {
var counter = 0;
for (let property in object) {
if (object.hasOwnProperty(property)) {
counter = object[property].length > counter ? object[property].length : counter
}
}
return counter
}
var obj = {
a: [2, 3, 4, 5],
b: [2, 3, 4],
c: [2, 3],
d: [2],
}
console.log(findLargestArrayInObject(obj)) // => should return the length of array (a)
There's something missing here that I can't quite grasp.