Last active
November 10, 2017 05:26
-
-
Save ukazap/af16148057d756289ab48e019c875cc8 to your computer and use it in GitHub Desktop.
Write a function that take source and convert to target.
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
let source = [ | |
{ | |
name: "Account A" | |
}, | |
{ | |
name: "Account B" | |
}, | |
{ | |
name: "Account C" | |
}, | |
{ | |
name: "Account D", | |
parent: "Account C" | |
}, | |
{ | |
name: "Account E", | |
parent: "Account C" | |
}, | |
{ | |
name: "Account F", | |
parent: "Account E" | |
}, | |
{ | |
name: "Account G", | |
parent: "Account F" | |
}, | |
] | |
let target = [ | |
{ | |
name: "Account A" | |
}, | |
{ | |
name: "Account B" | |
}, | |
{ | |
name: "Account C", | |
children: [ | |
{ | |
name: "Account D", | |
}, | |
{ | |
name: "Account E", | |
children: [ | |
{ | |
name: "Account F", | |
children: [ | |
{ | |
name: "Account G" | |
}, | |
] | |
}, | |
] | |
}, | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment