I've written this function in order to loop through some files and their children items depending on certain criteria. Depending on what the criteria is for the file, it will return true or false.
I've made a variable validFile to keep track of the return value.
I feel like there is a cleaner way to make the function more fluid....if someone can give me some pointers on how i can make this function more simple that'd be great.
function checkFile() {
var validFile;
if($scope.files.length) {
angular.forEach($scope.files, function(file) {
if(file.item && file.item.child.length > 1) {
angular.forEach(file.item.child, function(item) {
if(item.child.code === 8) {
validFile = true;
}
});
} else {
validFile = false;
}
});
} else {
validFile = false;
}
return validFile;
}
PS. the function works fine....just want to clean it up and refactor it to be neater
thanks
Aucun commentaire:
Enregistrer un commentaire