Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $('#lol').keypress(function(){
- var data = $('#lol').val().split('n');
- var result = data.filter((word, i, arr) => arr.indexOf(word) === i);
- $('#lol').val(result.join('n'));
- data.unique();
- });
- });
- (function() {
- "use strict";
- Array.prototype.unique = function unique() {
- var self = this;
- return self.filter(function(a) {
- var that = this;
- // console.log(that);
- if(!that[a]) {
- return that[a] = true;
- } else {
- alert("duplicate");
- return that[a] = false;
- }
- }, {});
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement