Last active
August 17, 2019 07:28
-
-
Save Kamilnaja/fec48e6dbad631112677ea94ce10896c to your computer and use it in GitHub Desktop.
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
// I think, that this is an interesting answer. Check if object key exists, if yes, double | |
const columns = [ | |
{ name: 'one', title: 'Order Number', id: 1 }, | |
{ name: 'two', title: 'Strawberry', id: 2 }, | |
{ name: 'three', title: 'Vanilla', id: 3 } | |
]; | |
const mapped = columns.map( | |
item => item.id ? item.id = item.id * 2 : item | |
) | |
console.log(columns); | |
// But it can be done better | |
const mapped = objArr.map(item => { | |
item.id = item.id * 2; | |
return item; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment