Guest User

Untitled

a guest
Jun 26th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bouncer(arr) {
  2.     var falsyList = [false, null, 0, "", undefined, NaN];
  3.   // Don't show a false ID to this bouncer.
  4.   for (i = 0; i < arr.length; i++) {
  5.    for (j = 0; j < falsyList.length; j++) {
  6.      if (falsyList[j] == arr[i]) {
  7.        arr.splice(i,1);
  8.      }
  9.      //WHY DOESNT THIS WORK!?!?!??!
  10.      if (arr[i] === null){
  11.        arr.splice(i,1);
  12.      }
  13.    }
  14.   }
  15.   return arr;
  16. }
  17.  
  18. bouncer([false, null, 0, NaN, undefined, ""]);
Add Comment
Please, Sign In to add comment