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

101
Views
Retrieve Key From an Object

How would I write a function that takes an object, and a string of the name of a key in that object and return the value of that key?

For example:

retrieveKey({name: 'Joel'}, 'name') // returns 'Joel'

retrieveKey({password: 'Fruit!'}, 'password') // returns 'Fruit!'

retrieveKey({name: 'Joel'}, 'age') // returns undefined

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Is this what you want?

let person1 = {name: "Joe", age: 18}

function getval(obj, key) {console.log(obj[key])}

getval(person1, "age") //returns 18

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