const colors = [{id: 1, color: "yellow", picked: true}, {id: 2, color: "green", picked: false}, {id: 3, color: "red", picked: false}];
const pickedColor = colors.find(color => color.picked)
console.log(pickedColor)
This snippet returns an object where picked color is located, in this case it's "yellow". However I need to get this value to be stored in const pickedColor
instead of having an entire object there. I know I can create another varibale and access it with dot notation, like const finalColor = pickedColor.color;
but is there a way to return just "yellow" directly into const pickedColor
?.