Hello, I am diving into the world of Typescript/Javascript and encountering some challenges when it comes to manipulating arrays of data. Please bear with me as I navigate through my learning curve.
Imagine having an array of objects structured like this:
items = [{header: "h1", value: "header 1 test"}, {header: "h2", value: "header 2 test"}]
My goal is to iterate through each object in the array, extract their values, and transform them into key:value pair objects. I aim to insert these transformed objects into a new array that should resemble the following:
myNewArray = [{"h1": "header 1 test"}, {"h2": "header 2 test"}]
Currently, I am working on an Angular project with TypeScript, but I am open to suggestions utilizing either Javascript or Typescript. Any modern techniques would be greatly appreciated.
Despite my attempts at using ES6 syntax like [element.header]: [element.value] to create a new array, I am still facing some challenges.
Thank you in advance for your help!