Reputation: 157
I am trying to change an array of strings to an array of key-value pairs as shown below.
["a","b"]
becomes [{"Info":"a"},{"Info":"b"}]
Any advice will be great.
Upvotes: 0
Views: 1209
Reputation: 24864
You can use map
:
const result = ['a', 'b'].map(item => ({ info: item });
Upvotes: 3