0

In the following example, I would like to use the "name" variable as a parameter for setting another variable for each value.

const series = [{
    name: 'Critical',
    color: _.find(palette.criticality, name => name.main)
  }, {
    name: 'High',
    color: _.find(palette.criticality, name => name.main)
}];

I can potentially (and probably should) do this by mapping the values after declaring the array, but would love to know if the above is even possible!

Yanis
  • 81
  • 5
  • Which `name`are you talking about? is it the one that storing 'Critical' and 'High'? – MEDZ Jan 02 '20 at 09:13
  • Does this answer your question? [Self-references in object literals / initializers](https://stackoverflow.com/questions/4616202/self-references-in-object-literals-initializers) also [this one](https://stackoverflow.com/questions/2787245/how-can-a-javascript-object-refer-to-values-in-itself) – Sebastian Kaczmarek Jan 02 '20 at 09:14

0 Answers0