Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var line = "the word in the word list are the best word in the word list a word could word for";
- var banned = "word";
- var arr = string.split(line, " ");
- var counts = {};
- var hold = {};
- for(var i = 0; i < arr.length; i++){
- var s = arr[i];
- if(s==banned){
- continue;
- }
- if(counts[s] != -1){
- if(counts[s] == undefined){
- counts[s] = 1;
- hold[s] = 1;
- }
- if(counts[s] == 1){
- counts[s] = -1;
- delete hold[s]
- }
- }
- }
- return Object.Keys(hold)[0];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement