Created
June 22, 2014 15:39
-
-
Save sorribas/6964d0d5a4df66cf046b to your computer and use it in GitHub Desktop.
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
var transverser = function(obj) { | |
var result = []; | |
var pusher = function(str, arr) { | |
arr.forEach(function(obj) { | |
if (obj.perms) return pusher(str + obj.value, obj.perms); | |
result.push(str + obj.value); | |
}); | |
}; | |
pusher('', obj) | |
return result; | |
}; | |
var res = transverser([{"value":1,"perms":[{"value":1},{"value":2},{"value":4}]},{"value":2,"perms":[{"value":1},{"value":2},{"value":4}]},{"value":4,"perms":[{"value":1},{"value":2},{"value":4}]}]); | |
console.log(res); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment