The Set constructor is not working

I’m trying to use Set constructor to remove duplicates from the array.
This is an example to show it is not working on fcc challenge console but working in browser console. Please check the image attached below


.

  **Please ignore the return args in the function**

function sym(args) {
console.log(new Set([1,2,3,3]))
return args;
}

sym([1, 2, 3], [5, 2, 1, 4]);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Find the Symmetric Difference

Link to the challenge:

I’m pretty sure it is “working”, it’s just not printing out pretty in the FCC console (but it is in the browser console as you noted in your image). So don’t let this stop you from using Set in your solution. But if you want to log the contents then you’ll have to look in your browser’s console to see them.

2 Likes

You can also kind-of override the issue, and see contents of set in the following way:

console.log(...new Set([1,2,3,3]))  // 1 2 3

Related github issue regarding print out in console: Set/Map logged as empty object in editor output · Issue #44306 · freeCodeCamp/freeCodeCamp · GitHub

3 Likes

Remember that the FCC console is not the browser console. It is part of the program to intercept and display the stuff being sent to the console, among other things. I guess it doesn’t know how to display a Set. If you feel strongly about it, you could go to the repo and see if there is a bug for it.

For me, I always had the browser console open too.

1 Like