function bouncer(arr) {
// Don't show a false ID to this bouncer.
var newArray = [];
for (var i =0; i<arr.length; arr++){
alert(arr[i]);
alert(Boolean(arr[i]));
}
//return arr.filter(Boolean(arr));
}
bouncer([7, "ate", "", false, 9]);
I’m getting the strange output: 7, true, 7, true, true, 7, true, a, true, false, false 1, true
rather than the expected: 7, true, “ate”, true, “”, false, false, false, 9, true.
I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.