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

173
Views
Error al enviar datos por lotes con una palabra clave y una declaración if

Estoy tratando de separar los datos en lotes, usando la reparación como separador de datos.
Dividir palabra clave = Reparación
Límite de Cu = 2,5

 [ {"engineSN":"20","timeRun":"30","Cu":"2"}, {"engineSN":"20","timeRun":"40","Cu":"2.01"}, {"engineSN":"20","timeRun":"59","Cu":"2.5", "Decision":"Repair"}, {"engineSN":"20","timeRun":"74","Cu":"5.4"}, {"engineSN":"20","timeRun":"90","Cu":"3.4", "Decision":"Repair"}, {"engineSN":"20","timeRun":"130","Cu":"5.6"}, {"engineSN":"20","timeRun":"1800","Cu":"10.3"}, ]

He intentado ejecutar hasta el primer índice de reparación usando un bucle for pero nada funciona

Código:

 let json = require("json.json"); let indexOfRepair = []; let indexTemp = 0; for(let i = 0; i < json.length; i++){ if(json[i].Decision == 'repair'){ indexOfRepair.push(i); } } let overLim = []; let underLim =[]; let isUnderLim = true; for(let i = indexTemp; i < json.length; i++){ indexTemp ++; if(json[i].Cu > 2.5){ isUnderLim = false; break; } else { underLim.push(json[i]); } }

No puedo entender por qué la separación de datos no me funciona

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Eso es porque usas la palabra clave "romper".

Terminará el "bucle for". Debe usar "continuar" para hacer lo siguiente sin terminar el "bucle for".

 let json = require("json.json"); let indexOfRepair = []; let indexTemp = 0; for (let i = 0; i < json.length; i++) { if (json[i].Decision == 'repair') { indexOfRepair.push(i); } } let overLim = []; let underLim = []; let isUnderLim = true; for (let i = indexTemp; i < json.length; i++) { indexTemp++; if (json[i].Cu > 2.5) { isUnderLim = false; break; // replace with continue } else { underLim.push(json[i]); } }
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!