i have a recursive function to find key and return his value, this is my code
$scope.findSelected = function (object, name){
//var key = '';
for (var i =0 ; i< object.length; i++){
var children =object[i];
var vName =children.Value.Name;
if(vName=== name ){
var key=children.Value.Key;
break;
}else {
key = $scope.findSelected(children.Children, name);
}
}
return key;
};
where vName === name i have to return key, but not work the loop play again, I think I've any dodgy thing and function return unidentified
returnonly returns from the current call of the function, not the uppermost recursive one? Andbreakonly breaks from the current loop, not all loops in your recursion?$scope.findSelectedin else branch and if it return not undefined - also break loop