Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 369 Bytes

javascript falsy bouncer.md

File metadata and controls

20 lines (15 loc) · 369 Bytes

Javascript falsy bouncer

  • Falsy: false, null, undefined, NaN, 0, ''。

falsy bouncer

  function bouncer(arr) {
    var holderArray = [];
    holderArray = arr.filter(removeFalseVal);
    return holderArray;
  }
  
  function removeFalseVal(value) {
    return Boolean(value);
  }
  
  bouncer([7, 'cate', '', false, 9, 0]);