I have the following input data:
var persons = [
{firstname : "Malcom", lastname: "Reynolds"},
{firstname : "Kaylee", lastname: "Frye"},
{firstname : "Jayne", lastname: "Cobb"}
];
I need to change the value of the key in every object so expected output data is:
persons = [
{fn : "Malcom", lastname: "Reynolds"},
{fn : "Kaylee", lastname: "Frye"},
{fn : "Jayne", lastname: "Cobb"}
];
I am using map function in JavaScript but it is not working.
persons.map(x => x.firstname=x.fn);
mapisn't the method you want