Skip to content

Instantly share code, notes, and snippets.

@leodevbro
Created January 6, 2023 18:38
Show Gist options
  • Save leodevbro/410e02011f603af964baf700a286e583 to your computer and use it in GitHub Desktop.
Save leodevbro/410e02011f603af964baf700a286e583 to your computer and use it in GitHub Desktop.
Special Task Solution
// more readable and maintainable (I converted it to TypeScript)
const makeLowerCaseAndfindLongWordsInReverseOrder = (text: string) => {
const lowerCased = text.toLocaleLowerCase();
const words = lowerCased.split(" ");
words.reverse();
const trimmedWords = words.map((w) => w.trim());
const longWords = trimmedWords.filter((w) => w.length > 5);
const result = longWords.join(", ");
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment