Answers for "javascript is array filled with empty string"

8

javascript not empty array not string

if (Array.isArray(array) && array.length) {
    // array exists and is not empty
}
Posted by: Guest on April-07-2020
0

how to check empty string array in javascript

function checkEmptyString(item){
     if (item.trim().length > 0) return false;
     else return true;
    };
    
function checkIfArrayContainsEmptyString(array) {
  const containsEmptyString = array.some(checkEmptyString);
  return containsEmptyString;
};
    
console.log(checkIfArrayContainsEmptyString(["","hey","","this","is","my","solution"]))
// *returns true*

console.log(checkIfArrayContainsEmptyString(["yay","it","works"]))
// *returns false*
 Run code snippetHide results
Posted by: Guest on March-23-2022

Code answers related to "javascript is array filled with empty string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language