-1

I'm having a strange issue with mapping an array to a new object type in javascript. I have a getter function like this:

get azOptions() {
    return this.arr?.map(az => {
        test:"asdf";
    });
}

...

console.log(this.azOptions);

The array contains 2 elements when I call the getter, but it maps to an array of 2 undefined elements as can be seen in this browser output:

enter image description here

Maxim
  • 227
  • 2
  • 14

1 Answers1

0

Try to do following:

get azOptions() {
   return this.arr?.map((az) => ({
     test: "asdf",
   }));
}

Your problem is, that you currently don't return an Object .

Sven Märki
  • 189
  • 1
  • 12
  • thanks, that worked. I thought the object after az=> would already be the value returned. – Maxim Nov 25 '22 at 11:41