How to check if array contains empty string in JavaScript

2 Answers

0 votes
const arr = ['c', 'javascript', null, '', 'c++', false];

const result = arr.includes('');

console.log(result); 

  
  
  
  
/*
run:
  
true
  
*/

 



answered Jun 27, 2022 by avibootz
0 votes
const arr = ['c', 'javascript', null, '', 'c++', false];

const result = arr.some(element => {
  if (element === '') {
    return true;
  }
});

console.log(result); 

  
  
  
  
/*
run:
  
true
  
*/

 



answered Jun 27, 2022 by avibootz

Related questions

...