Strange output when iterating through falsy bouncer

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var newArray = [];
  for (var i =0; i<arr.length; arr++){
  //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.

What on Earth is going on here?

I think arr++ in the for loop might be the problem.

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.


Thanks new here and have not gone through details on posting so will help when I do!