Return from angular.foreach is undefined
<p>I have a function like this that works, but I process the whole array before it returns:</p>

<pre><code>function getDefault(name, preferences){
    console.log("Getting " + name);
    var v;
    angular.forEach(preferences, function(value, key){
    console.log("Checking " + value.name);
    if(value.name == name){
        v = value.value;
        console.log("Got match, value = " + v);
    }
    });
    console.log("v is " + v);
    return v;
}
</code></pre>

<p>When I do this (return from within the <code>forEach</code> block, I get undefined, but it says that the correct value is returned.</p>

<pre><code>function getDefault(name, preferences){
    console.log("Getting " + name);
    var v;
    angular.forEach(preferences, function(value, key){
    console.log("Checking " + value.name);
    if(value.name == name){
        v = value.value;
        console.log("Got match, value = " + v);
        console.log("v is " + v);
        return v;  // The function returns but the value is undefined
    }
    });
}
</code></pre>

<p>s
What's the deal here?  Is angular somehow creating a strange scope that goes away?</p>