-
-
Save aliokan/7ee3ec104a8805f5f8b8a2de0316dbf6 to your computer and use it in GitHub Desktop.
prettify.js
This file contains 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
/* | |
Make the function more readable and maintainable | |
Please do not comment on this public gist (comments will be removed) | |
Please do not fork on this public gist - if you got here from | |
an application form, please reply privately on the form. | |
This is used as part of a hiring pipeline, I ask you to respect that. | |
*/ | |
function doStuff(text) { | |
const lowerCased = text.toLocaleLowerCase(); | |
const words = lowerCased.split(' '); | |
words.reverse(); | |
const trimmedWords = []; | |
for (let i in words) { | |
trimmedWords.push(words[i].trim()); | |
} | |
const longWords = []; | |
for (let i in trimmedWords) { | |
if (trimmedWords[i].length > 5) { | |
longWords.push(trimmedWords[i]); | |
} | |
} | |
let result = ''; | |
for (let i in longWords) { | |
result += longWords[i]; | |
result += ', '; | |
} | |
return result.slice(0, -2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment