Solution using Object.values
const arr1 = [{capacity: ""}, {color: ""}];
const arr2 = [{capacity: "full"}, {color: "blue"}];
const arr3 = [{capacity: ""}, {color: "blue"}];
function arePropertiesEmpty( arr){
for( let i = 0 ; i < arr.length ; i++){
// values is not empty
if( Object.values(arr[i])[0].length ) {
return false;
}
}
return true;
}
// another solution
function arePropertiesEmpty2( arr){
let filterArr = arr.filter(eliminateEmptyElementsFromArray);
function eliminateEmptyElementsFromArray( el ){
return Object.values(el)[0].length > 0
}
return filterdArr.length > 0 ? false : true;
}
console.log(arePropertiesEmpty(arr1));//true
console.log(arePropertiesEmpty(arr2));//false
console.log(arePropertiesEmpty(arr3));//false
console.log(arePropertiesEmpty2(arr1));//true
console.log(arePropertiesEmpty2(arr2));//false
console.log(arePropertiesEmpty2(arr3));//false