Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
I have an array full of objects. All objects have key author and publisher. I want to take out the publisher who publish most different authors

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 .

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

My suggestion would be to store every publisher's published authors into their respective arrays, and then use filter and indexOf to filter out the duplicates. Then, return the largest array.

Here is a link to how you would use filter and indexOf to filter duplicates.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda