Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda