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

205
Views
Function objectContains

I need to create a function that looks inside a nested object for a specific {key:value}.

The object, key, and value will be given as a parameter. If both the key and value are in the object together I have to return true, otherwise false

function objContains = function(obj, prop, value){
    for (let key in obj) {
      if (typeof obj[key] === 'object') {
        objContains(obj[key], prop, value)
      }
      if (obj.hasOwnProperty(prop) && obj[key] === value) {
        return true
      }
    }
    return false
  }

I tried this but I can´t make it work

about 4 years ago · Juan Pablo Isaza
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!