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

92
Views
Find value in an Object using only the Key JavaScript

I have an object containing a checklist below that I would like to get values from.

colors = {
    green: true, 
    blue: true, 
    red: true, 
    orange: false
}

How will I get the value (e.g. true/false) just by using the keys?

Pseudocode:

const isUsed = (color) => {
    return if true or false given the color
}

Expectations:

console.log(isUsed("green"));
//logs true
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

const colors = {
    green: true, 
    blue: true, 
    red: true, 
    orange: false
}


const isUsed = (color) => {
    return colors[color]
}

console.log(isUsed('green'))
console.log(isUsed('orange'))

about 4 years ago · Juan Pablo Isaza Report

0

const isUsed = color => colors[color]

This will return true or false if the value color exists in colors, or it will return undefined if it doesn't

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!