How to remove duplicates from string

To remove duplicate from string values use below formula


    <script src=""></script>
        $(document).ready(function() {
            $("#btn1").click(function() {
                var result = "Samsung|Galaxy;Apple|iPhone7;Samsung|Note;Apple|iPhone7";
                result = Array.from(new Set(result.split(';'))).toString();



    <p id="test1">This is a paragraph.</p>    
    <button id="btn1">Check Duplicate Value </button>


INPUT STRING: Samsung|Galaxy;Apple|iPhone7;Samsung|Note;Apple|iPhone7
OUTPUT/ RESULT STRING: Samsung|Galaxy,Apple|iPhone7,Samsung|Note


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s