Advertisement
Guest User

code

a guest
Apr 20th, 2018
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var line = "the word in the word list are the best word in the word list a word could word for";
  2. var banned = "word";
  3. var arr = string.split(line, " ");
  4. var counts = {};
  5. var hold = {};
  6. for(var i = 0; i < arr.length; i++){
  7.     var s = arr[i];
  8.     if(s==banned){
  9.     continue;
  10.     }  
  11.     if(counts[s] != -1){
  12.         if(counts[s] == undefined){
  13.             counts[s] = 1;
  14.             hold[s] = 1;
  15.         }
  16.         if(counts[s] == 1){
  17.             counts[s] = -1;
  18.             delete hold[s]
  19.         }
  20.     }
  21. }
  22.  
  23. return Object.Keys(hold)[0];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement