I have a small problem with replace words in html.
<p id ="demo">Hello, Hello how are you! </p> I want final result like this: Hello, how are you!
It should to filter it to remove duplicate items, join them back.
var span = document.getElementById('demo'), text = span.innerHTML.split('').filter(function (allItems,i,p) { return i == p.indexOf(allItems); }).join(''); span.innerHTML = text; <p id ="demo">Hello, Hello how are you </p>