Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
How can we check key avaibality in objects?

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)

As we know that, I have student variable which contain array of object.
Now, I want to check (find) or count which object has contained checked key. So How can I find and how many ways ?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Welcome to stack overflow Lokesh! For me, the simplest solution that I would do is to iterate over the array, and check for where the key checked is equal to checked. However, someone else might have a better solution.

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

If you want to count that, you could add a simple counter variable to the code to, like so.

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda