Skip to content

Instantly share code, notes, and snippets.

@jasper-lyons
Created December 4, 2017 12:05
Show Gist options
  • Save jasper-lyons/6b430c16092bde6954c277596ae99e40 to your computer and use it in GitHub Desktop.
Save jasper-lyons/6b430c16092bde6954c277596ae99e40 to your computer and use it in GitHub Desktop.
function onlyUniqueWords(string) {
return string.split(' ').reduce(function (arr, word) {
if (!arr) return arr;
if (arr.indexOf(word) > -1) return false;
return arr.concat(word);
}, []);
}
var passPhrases = `pphsv ojtou brvhsj cer ntfhlra udeh ccgtyzc zoyzmh jum lugbnk
...
juo pmiyoh xxk myphio ogfyf dovlmwm moevao qqxidn`.split("\n");
console.log(passPhrases.map(onlyUniqueWords).filter(Boolean).length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment