Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!