0

I have an array of color palettes as shown below. How can I get the key based on the value? For example, how can I get the key Tomato based on the value #D50000?

var arrColorPalette = [{
  "Tomato": "#D50000"
}, {
  "Flamingo": "#E67C73"
}, {
  "Tangerine": "#F4511E"
}];
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • 2
    If you can change this structure, I would change it so that the property names in the objects are consistent, for instance: `{name: "Tomato", value: "#D50000"}`. Having inconsistent keys like that makes for more work. – T.J. Crowder May 21 '19 at 09:15
  • Sadly, I can't change structure. :( – davidcafu412 May 21 '19 at 09:39

0 Answers0