Skip to content
Advertisement

Iterate through nested array of object in an Array of objects

Trying to make a select filter with all the unique coins, but not getting to the end of it correctly.

When looping through data I can get a list of all the coins like this.

JavaScript

I also want to use the Set method and spread operator to get just unique values but I’m not sure how to combine all these.

JavaScript

Advertisement

Answer

Start by combining all the coin values from all the currencies arrays using map, and flatMap, add that flattened array to a Set to dedupe the elements, and then spread the Set back out into an array.

JavaScript

Additional documentation

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement