How to remove all empty strings from an array in Node.js

1 Answer

0 votes
let arr = ['node.js', '', '', 'c', '', 'c++', '', '', 'php'];

arr = arr.filter(element => { return element !== ''; });

console.log(arr);




/*
run:

[ 'node.js', 'c', 'c++', 'php' ]

*/

 



answered Feb 17, 2022 by avibootz

Related questions

...