Here I am setting the empty object with key (publisher) and value author;
Also I tried and I push them in the empty array
let publisherAutors = {};
let pushedAutorsPerPublisher = [];
With this for loop i`m taking the elements from my library , which are books(objects), and i take out the publishers and the autors
for (let i = 0; i < library.length; i++) {
const element = library[i];
autorCount = 0;
I think my problem is here , with the if statements, i wanna compare but something is going wrong
if (
element.publisher === element.publisher &&
element.autor === element.autor
) {
console.log(`Yes`);
Here i push to the empty array
pushedAutorsPerPublisher.push(element.publisher, element.autor);
console.log(element.publisher, element.autor);
}
Here I`m adding key/ value to the empty object, but Its not helping me , because they goes only once in the empty object
publisherAutors[element.publisher] = element.autor;
}
console.log(publisherAutors);
console.log(pushedAutorsPerPublisher);
My main problem is to make object , or array that holds them and count how many different authors have each publisher .