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

265
Views
(ES6) ¿Por qué el valor de las variables vuelve al valor inicial después de salir del bucle?

Inicialicé dos variables count y user , y cambié su valor en el bucle. ¿Por qué la función siempre devuelve [0, 0] al finalizar?

Aquí está mi código:

 function getMonthSubs(month) { // month are the name of folders var cb = {count: 0, user: 0}, userTemp = []; readdir('./log/' + month, 'utf-8', function (err, files) { // files eg '2021_11_30.json' if (err) return [-1, -1]; else { for (let j = 0; j < files.length; j++) { let temp = JSON.parse(readFileSync('./log/' + month + '/' + files[j], 'utf-8')); for (var key in temp) { cb.count += temp[key].length; if (!userTemp.includes(key)) { userTemp.push(key); cb.user++; } } } } }); return Array(cb.count, cb.user); // [0, 0] }
about 4 years ago · Juan Pablo Isaza
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!