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
cómo aumentar el valor de un objeto dependiendo del nombre de la clave

Quiero aumentar el valor dependiendo del nombre de la clave. Tengo una matriz con puntuaciones:

 [50,50,60,70,80,90,90,100]
 Grade A: score<100 and score>=90 Grade B: score<90 and score>=80 Grade C: score<80 and score>=60 Grade D: score<60 and score>=0

Al final, quiero obtener un objeto con puntajes contables:

 {A:0, B:0, C:0, D:0 };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede tomar un Proxy y cambiar las propiedades dependientes.

 const table = { S: 0, A: 0, B: 0, C: 0, D: 0, X: 0 }, change = new Proxy(table, { set: function(obj, prop) { if (prop === 'B') obj.S++; obj[prop]++; return true; }, }); change.B++; console.log(table);

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!