Check if an array is filled with empty strings

Let's assume the following two arrays:

javascript
let array_1 = ['Erik', '', 'Andrea', 'Paula', ''];
let array_2 = ['', '', '', '', ''];

To check if an array is filled with empty strings, you can use the Array.prototype.every() function.

Example:

javascript
let isEmpty_1 = array_1.every(element => element === ''); // false
let isEmpty_2 = array_2.every(element => element === ''); // true

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.