Skip to content

Instantly share code, notes, and snippets.

@aliokan
Forked from omesser/prettify.js
Created January 27, 2023 08:25
Show Gist options
  • Save aliokan/7ee3ec104a8805f5f8b8a2de0316dbf6 to your computer and use it in GitHub Desktop.
Save aliokan/7ee3ec104a8805f5f8b8a2de0316dbf6 to your computer and use it in GitHub Desktop.
prettify.js
/*
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