Spaces added to Arrays. Help! Bug? or is it me?

In the JavaScript console, for the last two days, my arrays have been logging with a space after the last element (i.e. [1, 2, 3 ]). This has prevented any of my challenges involving arrays from being successful even if the code is correct.

Example A:

let testArr = [1, 2, 3];

… then the console prints …

[ 1, 2, 3 ]

Example B:

let testArr = ["cat", "dog", "bird"];

… then the console prints …

[ 'cat', 'dog', 'bird' ]

Both examples have a space at the beginning and ending. I’ve googled and can’t find anything.
-Checking testArr.length returns the correct number of elements.

  • Checking testArr[2].length returns the correct number of letters if it’s a string.
  • Checking typeof testArr[2] returns the correct type of number or string.

Please help. :face_exhaling:

which challenge was this? (post a link to it so we can try your code there)

It’s happening on every challenge. Even if I go back to challenges that are complete and type in this code, I get the exact same result. Makes believe there’s an issue with my console but honestly don’t know.

This was the first challenge where it happened …

But as I mentioned above, even if I go back to previous challenges or future challenges, I know get this exact same result.

Those were just from me testing the console after I ran into issues. They were not part of any challenge. I was trying to problem solve with something very generic.

I’ll have to go back and rewrite my code. I didn’t save it because the challenge wouldn’t accept. Eventually had to just copy and past the solution. I know the code I wrote worked as I tested every situation given and achieved the result required, just with that extra space.

Give me a few minutes while I go back and put my code in …

Never mind. When retyping my code, I realized I left the console.log statement in the function and deleted the return statement … which is why the challenge failed.

This is the code I used for the challenge …
function bouncer(arr) {
let newArr = ;
for (let i = 0; i < arr.length; i ++) {
if (!!arr[i] === true) {
return newArr
bouncer([7, “ate”, “”, false, 9]);

But still curious as to why the extra space is being added to the arrays now. :thinking:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.