Created
January 27, 2016 19:10
-
-
Save sibelius/7790ef72699683eaae6b to your computer and use it in GitHub Desktop.
Frontend exercise - Async
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
Exercise to hire new front-end in the future | |
You have a list of string (var regions = ['Brazil', 'SP', 'São Carlos', 'Caaso'] | |
Each one of these strings represents a region, the first region is the parent (includes) the second region, and so on. | |
You have the following POST route /region, that accepts name and parentId, and return the ID of the region created | |
Write a program in **JS** that saves all the regions taking into consideration their hierarchy: | |
Example of algorithm: | |
Save Brasil | |
Save SP as Brasil being its father | |
Save São Carlos as SP being its father | |
Save Caaso as São Carlos being its father | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment