I have 1 object that contains a nested child, as shown below:
$scope.artists.materials.items[]
Now I will have several artists who will contain a list of elements, but in this I want to check the total length of each element of artists and if a discrepancy is found, then I want to return true or false.
The problem is that I do not have elements for any artist, I get false
The idea here is to keep the length of the elements from the first artist and make sure that they all have the same length of elements.
The code:
function checkItemsValidity() {
for (var i = 1; i < $scope.artists.length; index++) {
if ($scope.artists[i].materials.items != undefined && $scope.artists[0].materials.items) {
if($scope.artists[i].materials.items.length != $scope.artists[0].materials.items[0].length) {
return false;
}
}
return false;
}
return true;
}
Case 1 . In the case of only one artist, then return true, because no other artist compares
2. 2- true else false;
3. 3- 2 artist1 2 5 artist3, false;
- ?