Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to remove duplicates in a csv field
const removeDuplicates = csvStr => [...new Set(csvStr.split(',').map(tag => tag.trim()))].join(', ');
@magician11

This comment has been minimized.

Copy link
Owner Author

commented Dec 27, 2018

some examples..

removeDuplicates('bob, 1, hello, john, 2, 1');
'bob, 1, hello, john, 2'

removeDuplicates('andrew, 3, 3, 3, Golightly');
'andrew, 3, Golightly'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.