Skip to content

Instantly share code, notes, and snippets.

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

This comment has been minimized.

Copy link
Owner Author

@magician11 magician11 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