Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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;
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement