function bouncer(arr) { // Don't show a false ID to this bouncer. var a = []; var count = 0; for (var i = 0; i < arr.length; i++) { if (arr[i]) { console.log(count); a[count] = arr[i]; count++; } } return a; } bouncer([7, "ate", "", false, 9]);