Forum Discussion
Oh, this is AWESOME! While the scenario I created isn’t exactly what I needed (I was trying to keep it simple), the solution you provided should be enough for me to run with. I’m gonna try it out now. Thanks so much for the assist!
ok great, feel free to ask if you need further help.
- alex_panganiban7 years agoContributor
Hi CJ, your solution has been really helpful to me. Thank you so much. I have an add-on question about this solution though. As it’s building the new array using the reduce statement you passed on to me, how can I insure that I’m not putting duplicate values into it? Hoping you can help.
Thanks, Alex
- cjhoward187 years agoEmployee
glad it was helpful.
You can use a map to store your values instead of an array and store the values as your keys. Maps do not allow for duplicate key entries, which would take care of this problem for you, and you could collect your ‘values array’ by using keys() method described here:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439367/Object+Functions+and+Properties#ObjectFunctionsandProperties-keysThis is just one solution, there are many ways you can keep track of this if needed.