In my current project, I am working with an array of objects that looks something like this:
$scope.objectArray = [
{Title: 'object1', Description: 'lorem', Value: 57},
{Title: 'object2', Description: 'ipsum', Value: 32},
{Title: 'object3', Description: 'dolor', Value: 135}
]
My goal is to check and return true if all the objects in this array have a value stored within the 'value' property.
While considering different approaches, I am currently using a forEach loop. However, I wonder if there might be a more efficient way to achieve the same result.
var isTrue = true;
angular.forEach(objectArray, function(o){
if (!o.Value){
isTrue = false; // change variable 'isTrue' to false if no value
}
});