How to keep only none falsy numbers in an array with Node.js

1 Answer

0 votes
let array = [1, 3, null, "node.js", "", undefined, 9, , , undefined, 0, , 8, 4.08, 90];
   
array = array.filter(Number) 
  
console.log(array);

  
  
/*
  
[ 1, 3, 9, 8, 4.08, 90 ]
      
*/

 



answered Mar 18 by avibootz
...