Last active
November 13, 2022 10:29
-
-
Save eoamusan/6a256470e0a6b8903b3cb154c5348df9 to your computer and use it in GitHub Desktop.
javascript - prettity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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