Last active
January 10, 2017 21:18
-
-
Save veered/b6ba8c4d202725e9b1a6 to your computer and use it in GitHub Desktop.
Get Value Challenge
This file contains hidden or 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
function get(doc, path) { | |
} | |
doc = { | |
'a': { | |
'b': { | |
'c': 'hello' | |
}, | |
'd': { | |
'c': 'sup', | |
'e': { | |
'f': 'blah blah blah' | |
} | |
} | |
} | |
} | |
get(doc, 'a.d.e.f') | |
// {'a.d.e.f': 'blah blah blah'} | |
get(doc, 'a.*.c') | |
// {'a.b.c': 'hello', 'a.d.c': 'sup'} | |
get(doc, 'a.*.e') | |
// {'a.d.e': {'f': 'blah blah blah'}}} | |
get(doc, 'a.b.c.e.*') | |
// {} | |
get(doc, '*') | |
// {'a':{'b':{'c':'hello'},'d':{'c':'sup','e':{'f':'blah blah blah'}}}} | |
get(doc, '') | |
// {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment