JSFiddle - React, Tailwind, and code Playground
by vrmtm
JavaScript
let keys = ["Title", "ID"];
let data = [
{ Title: "title1", ID: "1", Version: "1.1" },
{ Title: "title2", ID: "2", Version: "1.2" },
{ Title: "title3", ID: "3", Version: "1.3" }
]
const result = data.map(item => {
return keys.reduce((current, next) => {
current[next] = item[next];
console.log(current)
return current;
}, {});
});
console.log(result);