Learn Functional Programming by Building a Spreadsheet - Step 102

Tell us what’s happening:

I’ve tried everything my smooth brain could come up with and I can’t get it right. I’ve opted for making a Set since it takes no duplicates, but I get “Reference Error: el is not defined” and I really don’t know what to try anymore

Your code so far

nodupes: nums => nums.map((el), () => new Set().map())

Your browser information:

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

Challenge Information:

Learn Functional Programming by Building a Spreadsheet - Step 102

what do you want your map callback to be? right now it is el, which is not a function and is not defined anywhere, so you get the error

okay, I feel this is closer but i still get an error which i’ve gotten before:

nums => nums.map((el) => new Set(nums[el]).map())

“[TypeError: number 2 is not iterable (cannot read property Symbol(Symbol.iterator))]”

So now I’m making a mistake regarding parenthesis/keys?

I don’t understand what you want to do honestly, why do you have a map call inside a map callback? what do you need the second one for? why are you creating a set of a single element and calling map on it?

To be honest I’m not really sure either. I’m trying to make a Set out of the values of “nums” first, and then make the set an array again? Maybe this is not the right approach at all

That doesn’t look like something you need map for, map can’t change an array into a set, it just returns a different array

1 Like

Hello again, I managed to do it by making a new Set from array first, and then Array.from(). I’m sorry for the mess.

Still, I’m wondering how this could be done with map(), and maybe filter() replace(). It probably has multiple correct answers and I’m just trying to understand what are my options and what is better to do. Thank you for your patience

EDIT: I’m just now looking at the recommended solution shown in the next step where spread is used.

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