Skip to content

Instantly share code, notes, and snippets.

@eoamusan
Last active November 13, 2022 10:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eoamusan/6a256470e0a6b8903b3cb154c5348df9 to your computer and use it in GitHub Desktop.
Save eoamusan/6a256470e0a6b8903b3cb154c5348df9 to your computer and use it in GitHub Desktop.
javascript - prettity
function doStuff(text) {
// Convert the text to lower characters
const lowerCased = text.toLocaleLowerCase();
// Split the characters with the space delimeter
const words = lowerCased.split(' ');
// Reverse split array
words.reverse();
let result = '';
// Check each word in array, trim and return only words with length greater than 5
for (let i in words) {
const trimmedWord = words[i].trim();
if (trimmedWord.length > 5) {
result += trimmedWord;
result += ', ';
}
}
// Remove excess comma and space at end
return result.slice(0, -2);
}
@omesser
Copy link

omesser commented Nov 13, 2022

hi @eoamusan
This fork is linked from my original and is public, please remove it.
I explicitly ask to avoid forking or commenting in the gist
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment