im new to javascript and lets say i have an array of objects (books) like this:
let books = [{"pubDate":"2014", "authors":["John","Bob","Tom"], "name":"Book 1"}, {"pubDate":"2020", "authors":["Bob","Greg"], "name":"Book 2"}]
let authorsFrequency = getFrequency(books);
console.log(authorsFrequency) // expected result {"Bob":2,"Tom":1,"Greg":1,"John":1}
How could i properly build this getFrequency function? I've seen some similar questions like this one: Counting the occurrences / frequency of array elements
But not one as deep as my example.
Results order doesn't matter, infact the fastest the better since i need to loop through 30.000 books.
Thank you very much for your time.