Last active
October 29, 2022 16:17
-
-
Save starlabman/07840c736680f382dc10ef519e884065 to your computer and use it in GitHub Desktop.
Javascript and typescript test
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