0

How do I map an array of strings to be an array of JSON objects? I have tried the below in the console

>> entityTypes = ["library"]
Array [ "library" ]

>> entityTypes.map(type => {name: type});
Array [ undefined ]

The resulting array is undefined. I can hard-code things and they look fine

>> arr = [{name: "library"}]
Array [ {…} ]

So not sure what's going wrong with my map function.

Dave
  • 15,639
  • 133
  • 442
  • 830

0 Answers0