SHARE
TWEET

Untitled

a guest Jun 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.   $('#lol').keypress(function(){
  3.     var data = $('#lol').val().split('n');
  4.     var result = data.filter((word, i, arr) => arr.indexOf(word) === i);
  5.     $('#lol').val(result.join('n'));
  6.     data.unique();
  7.   });
  8. });
  9.  
  10. (function() {
  11.     "use strict";
  12.  
  13.     Array.prototype.unique = function unique() {
  14.         var self = this;
  15.         return self.filter(function(a) {
  16.             var that = this;
  17.             // console.log(that);
  18.             if(!that[a]) {
  19.                 return that[a] = true;
  20.             } else {
  21.                 alert("duplicate");
  22.                 return that[a] = false;
  23.             }
  24.         }, {});
  25.     }
  26. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top