Question: I have an array of objects in the following form

```
var data = [{"name":"Lenovo Thinkpad 41A4298","website":"google"},
{"name":"Lenovo Thinkpad 41A2222","website":"google"},
{"name":"Lenovo Thinkpad 41Awww33","website":"yahoo"}];

```

I want to convert this to

```
var data = [{"Brand":"Lenovo Thinkpad 41A4298","Link":"google"},
{"Brand":"Lenovo Thinkpad 41A2222","Link":"google"},
{"Brand":"Lenovo Thinkpad 41Awww33","Link":"yahoo"}];

```

How do I achieve this?

Answer: 
You can use `map` to loop thru the array. Without using the key, you can use `Object.values` to convert the object into an array. Assign the first element of the array on Brand and the second to Link to form a new object.

```js
var data = [{
    "name": "Lenovo Thinkpad 41A4298",
    "website": "google"
  },
  {
    "name": "Lenovo Thinkpad 41A2222",
    "website": "google"
  },
  {
    "name": "Lenovo Thinkpad 41Awww33",
    "website": "yahoo"
  }
];

var result = data.map(o => {
  let v = Object.values(o);
  return {"Brand": v[0],"Link": v[1]};
});

console.log(result);
```
Like this:

```js
var data = [{ "name": "Lenovo Thinkpad 41A4298", "website": "google" },
{ "name": "Lenovo Thinkpad 41A2222", "website": "google" },
{ "name": "Lenovo Thinkpad 41Awww33", "website": "yahoo" }];

const newData = data.map(obj => ({ Brand: obj.name, Link: obj.website }));
console.log(newData);
```

---

To make it more dynamically, you can create some mappings:

```js
    var data = [{ "name": "Lenovo Thinkpad 41A4298", "website": "google" },
    { "name": "Lenovo Thinkpad 41A2222", "website": "google" },
    { "name": "Lenovo Thinkpad 41Awww33", "website": "yahoo" },
    { "rate": "25", "review": "Well done" }];

    const mappings = {
      name: 'Brand',
      website: 'Link',
      review: 'Review',
      rate: 'Rate'
    }

    const newData = data.map(obj => {
      const newObj = {};
      const keys = Object.keys(mappings);
      keys.forEach(key => {
         if (obj[key]) {
           const newName = mappings[key];
           newObj[newName] = obj[key];
         }
      });
      return newObj;
    });

    console.log(newData);
```

Then you can just change "mappings" based on source data or whatever you want to do with it.