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

129
Views
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 answers
Answer question

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 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!