Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created January 27, 2016 19:10
Show Gist options
  • Save sibelius/7790ef72699683eaae6b to your computer and use it in GitHub Desktop.
Save sibelius/7790ef72699683eaae6b to your computer and use it in GitHub Desktop.
Frontend exercise - Async
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