Skip to content

Instantly share code, notes, and snippets.

@nshimiye
Created November 7, 2018 01:49
Show Gist options
  • Save nshimiye/7c50dc8898473667e752e81a0e6736d7 to your computer and use it in GitHub Desktop.
Save nshimiye/7c50dc8898473667e752e81a0e6736d7 to your computer and use it in GitHub Desktop.
code with object.assign in it
import "babel-polyfill";
const backendResponse = [
{ title: '', timestamp: '1960-04-15T18:34:38+05:00' },
{ title: '', timestamp: '2007-05-15T18:34:38+05:00' }
];
const timeline = backendResponse.map(event => {
const date = new Date(event.timestamp).toLocaleDateString('en-US');
return Object.assign(event, { date }); // <=
});
console.log('timeline', timeline);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment