function findBiggestPublisher(arr) {
for (let i = 0; i < arr.length; i++) {
const element = arr[i];
if (publisherBooks.hasOwnProperty(element)) {
publisherBooks[element] = publisherBooks[element] + 1;
} else {
publisherBooks[element] = 1;
}
}
console.log(publisherBooks);
console.log(pushedPublishers);
let publisherNameLow = "";
let publisherNameHigh = "";
let publisherHigh;
let publisherLow;
for (const [key, value] of Object.entries(publisherBooks)) {
if (!publisherHigh || value > publisherHigh) {
publisherHigh = value;
publisherNameHigh = key;
}
if (!publisherLow || value < publisherLow) {
publisherLow = value;
publisherNameLow = key;
}
//proverka za broi izdateli s 1 kniga
if (value == 1) {
console.log(`${key} has only ${value} book`);
}
}
console.log(`${publisherNameHigh} has ${publisherHigh} books`);
console.log(`${publisherNameLow} has ${publisherLow} books`);
}
findBiggestPublisher(pushedPublishers);
// So far I takeout the publishers with the most books and the fewest and the one with only 1 too.
Now I need to take out the publisher with the most different authors published.
Any advice about with what logic to compare them ?