Skip to content

Instantly share code, notes, and snippets.

@umutbasal
Last active January 10, 2022 00:32
Show Gist options
  • Save umutbasal/d47f8a68bba991c9ba850cc92dfa0181 to your computer and use it in GitHub Desktop.
Save umutbasal/d47f8a68bba991c9ba850cc92dfa0181 to your computer and use it in GitHub Desktop.
const words = require('./words.json');
const countVowels = ([...word]) => word.filter(l => l.match(/[aeiou]/i)).length;
const all = words.filter(([...word]) => {
return word.length == [...new Set([...word])].length;
}).sort((a, b) => countVowels(b) - countVowels(a));
console.log("most vowels: ",
all[0]
);
const filterOut = (word, out) => !word.match(`[${out}]`);
console.log("least vowels and exclude first word letters: ",
silence = all.filter(word => filterOut(word, all[0])).slice(-1)[0]
);
console.log("exclude both words: ",
all.filter((word) => filterOut(word, all[0]) && filterOut(word, silence))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment