Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let objects = JSON.parse(input);
- let result = objects.reduce((acc, x) => Object.assign(acc, x), {});
- // [...acc, ...x]
- console.log(result);
- }
- solve(`[{"canMove": true},{"canMove":true, "doors": 4},{"capacity": 5}]`);
- // result is {canMove: true, doors: 4, capacity: 5}ove: true, doors: 4, capacity: 5}
Add Comment
Please, Sign In to add comment