Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
How to print the 2 most repeated strings in an array

First of all I apologize this may be trivial but I'm stuck, I search in an array the string that repeats the most and print the 2 that repeat the most. I have wanted to do Case or multiple if, but I also get the idea of a map(), in short I do not find an efficient way to implement it. thank you very much in advance

const clientes=['cliente1','cliente2', 'cliente3', 'cliente2', 'cliente3', 'cliente4'];
for(let x = 0; x < clientes.length; x++) 
{

}
console.log('CLIENTES', clientes)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Loop and count. your approach goes to right direction.

let counts = {};
const clientes = ['cliente1','cliente2', 'cliente3', 'cliente2', 'cliente3', 'cliente4'];

clientes.forEach(function (x) { counts[x] = (counts[x] || 0) + 1; });
console.log(counts)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda