Skip to content

Instantly share code, notes, and snippets.

@rxluz
Created December 11, 2017 12:29
Show Gist options
  • Save rxluz/5234390fefe8e4b22e493b003f8af95c to your computer and use it in GitHub Desktop.
Save rxluz/5234390fefe8e4b22e493b003f8af95c to your computer and use it in GitHub Desktop.
const initialArray = [
{
name: 'Ricardo',
surname: 'Luz',
age: 32
},
{
name: 'John',
surname: 'Doe',
age: 40
}
];
const endArray = initialArray.reduce(
(accumulator, value) => [
...accumulator,
{
fullName: `${value.name} ${value.surname}`,
age: value.age
}
],
[]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment