Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function objectFactory(str) {
- let arr = JSON.parse(str).reduce((acc, cur) => {
- return acc = Object.assign(acc, cur)
- },{})
- return arr;
- }
- objectFactory(
- `[
- {"canMove": true},
- {"canMove":true, "doors": 4},
- {"capacity": 5}
- ]`
- )
- objectFactory(`[{"canFly": true},{"canMove":true, "doors": 4},{"capacity": 255},{"canFly":true, "canLand": true}]`)
Advertisement
Add Comment
Please, Sign In to add comment