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

134
Views
¿Cómo podemos verificar la disponibilidad de claves en los objetos?

 const student= [ { student_id: 0, name: "Rhoda Salas", checked:"checked" }, { student_id: 1, name: "Jewell Avery" }, { student_id: 2, name: "Susanne Harris", checked:"checked" } ] console.log(student)

Como sabemos, tengo una variable de estudiante que contiene una matriz de objetos.
Ahora, quiero verificar (encontrar) o contar qué objeto ha contenido la clave marcada. Entonces, ¿cómo puedo encontrar y de cuántas maneras?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

¡Bienvenido a Stack Overflow Lokesh! Para mí, la solución más simple que haría es iterar sobre la matriz y verificar dónde la clave verificada es igual a verificada. Sin embargo, alguien más podría tener una mejor solución.

 for (var i = 0; i < student.length; i++) { if (student[i].checked === 'checked') { console.log(student[i]); } }

Si desea contar eso, puede agregar una variable de contador simple al código, así.

 var counter = 0; for (var i = 0; i < student.length; i++) { if (student[i].checked === 'checked') { counter++ console.log(student[i]); } }
about 4 years ago · Santiago Gelvez 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!