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.

Can you please provide the url of the challenge containing the code you posted above?

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.

The extra space is not a problem. It is just the way your browser’s console displays the array. You said this is causing you to not pass tests for a challenge? If so, can you provide the challenge url and the code you wrote?

You mentioned:

I am not sure what challenge this is from.

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:

I explained this in my second reply.

I can create an array like:

const arr = [         "a",          "b", 2,        6 ];
console.log(arr); // my browser displays ['a', 'b', 2, 6]

Also, keep in mind, the FCC console is not a real browser console. It is an emulated console. Type the same code in various browsers’ consoles and you will possibly see different variations of spacing. The important thing is that the array can be written with spaces but it does not change the fact that JavaScript recognizes it as an array.