Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bouncer(arr) {
- var falsyList = [false, null, 0, "", undefined, NaN];
- // Don't show a false ID to this bouncer.
- for (i = 0; i < arr.length; i++) {
- for (j = 0; j < falsyList.length; j++) {
- if (falsyList[j] == arr[i]) {
- arr.splice(i,1);
- }
- //WHY DOESNT THIS WORK!?!?!??!
- if (arr[i] === null){
- arr.splice(i,1);
- }
- }
- }
- return arr;
- }
- bouncer([false, null, 0, NaN, undefined, ""]);
Add Comment
Please, Sign In to add comment