Javascript & jQuery Project to Remove Duplicate or Repeating Strings From Textarea in Browser Using HTML5 & CSS3 Full Project For Beginners

 

 

index.html

 

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div>
  <textarea name="" id="" cols="30" rows="10"></textarea>
<br>
<button>Remove Duplicates</button>
</div>

 

 

 

style.css

 

 

div{
  padding: 20px;
}

 

 

script.js

 

 

$(document).ready(function(){
  $('button').click(function(){
    var data = $('textarea').val();
    var result = data.split(/\s/g).filter((word, i, arr) => arr.indexOf(word) === i);
    $('textarea').val(result.join(' '));
  });
});

Leave a Reply