I am new to Typescript/Javascript and I am having trouble manipulating an array of data so I apologize in advance for my incompetency.
Given an array of objects with values such:
items = [{header: "h1", value: "header 1 test"}, {header: "h2", value: "header 2 test"}]
I want to be able to loop through each object in the array and take their values and turn them into a key:value pair object and insert that into a new array that should look like this.
myNewArray = [{"h1": "header 1 test"}, {"h2": "header 2 test"}]
I am working with Angular and TypeScript but I believe both Javascript and Typescript should work. Feel free to use any modern techniques. I have tried creating a new array, using ES6 [element.header]: [element.value] and it still giving me trouble.
Thanks!