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
const colors = {
green: true,
blue: true,
red: true,
orange: false
}
const isUsed = (color) => {
return colors[color]
}
console.log(isUsed('green'))
console.log(isUsed('orange'))
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