Created
January 9, 2015 14:37
-
-
Save ryanguill/eb8da9aa430db7a6d39d to your computer and use it in GitHub Desktop.
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
| <html> | |
| <head> | |
| <title></title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script> | |
| <script> | |
| var set = { | |
| one : { | |
| alphabet : "a", | |
| maori : "tahi", | |
| roman : "i", | |
| ordinal : "first" | |
| }, | |
| two : { | |
| alphabet : "b", | |
| maori : "rua", | |
| roman : "ii", | |
| ordinal : "second" | |
| }, | |
| three : { | |
| alphabet : "c", | |
| maori : "toru", | |
| roman : "iii", | |
| ordinal : "third" | |
| }, | |
| four : { | |
| alphabet : "d", | |
| maori : "wha", | |
| roman : "iv", | |
| ordinal : "fourth" | |
| } | |
| }; | |
| function getOrderedSubset (keys, data) { | |
| return _.map(_.pick(data, keys), function(value, key) { | |
| value.label = key; | |
| return value; | |
| }); | |
| } | |
| console.log(getOrderedSubset(["four", "two"], set)); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment