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

122
Views
Conversión de matriz de cadenas a matriz de objetos: cada tercer índice

Estoy tratando de convertir una matriz de cadenas en una matriz de objetos después de cada tercer índice.

Aporte:

 let tee = [ 'Blue', '130', '70.8', 'Blue', '128', '708', 'White', '124', '68.2' ]

Código:

 function fillTeeBoxes(holesAmount) { for (let i = 0; i < holesAmount.length; i++) { let teeBox = ['tee', 'slope', 'rating'] let holeData = {}; for (let j = 0; j < 3; j++) { holeData[teeBox[j]] = parseInt(getTeeBoxes[i]) || getTeeBoxes[i] i++ }; teeBoxes.push(holeData) }; };

Rendimiento esperado:

 tee = [ {tee: 'Blue', slope: 130, handicap: 70.8} {tee: 'Blue', slope: 128, handicap: 70.8} {tee: 'White', slope: 124, handicap: 68.2} ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Podemos usar un bucle for e iterar en pasos de 3:

 let tee = [ 'Blue', '130', '70.8', 'Blue', '128', '708', 'White', '124', '68.2' ]; var output = []; for (var i=0; i < tee.length; i+=3) { var obj = {tee:tee[i], slope:tee[i+1], handicap:tee[i+2]}; output.push(obj); } console.log(output);

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!