Created
November 7, 2018 01:49
-
-
Save nshimiye/7c50dc8898473667e752e81a0e6736d7 to your computer and use it in GitHub Desktop.
code with object.assign in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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