Javascript Sets not logging on freeCodeCamp editor

Jus try this code in the editor:

const test = new Set([1,2,3,4,5])

and it will log an empty object, while if you do the same in the any other place:


Any solution for this?

The set actually works fine though:

const set1 = new Set([1, 2, 3, 4, 5]);

// expected output: true

// expected output: true

// expected output: false

Yeah, it’s kinda strange, even if I try to convert a Set to an Array it will not show up

const test = new Set([1,2,3,4,5])
console.log(new Array(test));
//output : [ {} ]

Yea, console logging can make strange output.

I think this is just a quirk with the FCC console logging. If you open up your browsers console in dev tools you should see that logging is working properly. So Sets are working in FCC, just not logging properly.

Thanks, I have changed the title so it will be more specific. I think now I only need to wait until it’s solved.

Thanks for the answers

This shouldn’t keep you from passing challenges. It is merely a quirk with logging to the console pane in FCC. I suppose you could open up a github issue, but you shouldn’t need to wait for this in order to do the challenges.

1 Like

Thanks, I imagine that I still can use Sets with the browser console, but I managed to solve the challenge without using sets and as you say I can still solve them even with this quirk.

Thanks for the answers!!

The editor output can be a little weird at times. There is some proxy console/logger code in a few different places. Which I think is also why the other console variants won’t work with the output (like dir/table/error). It’s a custom logger is what I’m basically trying to say. There is also a transpiler and other stuff (like comment removal) that the code is run through that sometimes may also affect the output I think.

I’m sure if we had a challenge that taught Set/Map the output would have been fixed so the logging of it was correct.

Here is an issue with some other different log issues (some are fixed now)

Not sure if it was @joshua.rod that opened an issue for this or what but here it is anyway.

1 Like

Yes, it was me. Thanks for the contribution!!

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