Skip to content

Instantly share code, notes, and snippets.

@jkwok91
Last active January 13, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkwok91/d557c96ddf08c9619037 to your computer and use it in GitHub Desktop.
Save jkwok91/d557c96ddf08c9619037 to your computer and use it in GitHub Desktop.
recruiters scraping github could put in a little more effort. especially when addressing me as JESSICA in all caps
/* test cases
assert is just a return a===b function. we all know this. these are strings. everyone relax.
assert("Jessica",format("JESSICA"));
assert("Jessica Kwok",format("JESSICA KWOK"));
assert("Jessica Kwok-Kwok",format("JESSICA KWOK-KWOK"));
assert("Jessica Kwok-$wok",format("JESSICA KWOK-$WOK"})); // this fails because i don't care enough
assert("Jessica Kwok-$$$$",format("JESSICA KWOK-$$$$"));
assert("J'essica",format("J'ESSICA")); // this fails too because am i a mind reader how should i know how you want your name formatted
*/
function format(name) {
return name.toLowerCase().replace(/\b([a-z])/g,function(l) { return l.toUpperCase(); });
}
function firstNameOnlyAnyway(name) {
return format(name.split(" ")[0]);
}
@jkwok91
Copy link
Author

jkwok91 commented Jan 13, 2016

check out this hideous shit

function format(name) { return name.toLowerCase().replace(/^(\w)/,function(f) { return f.toUpperCase(); }).replace(/(\w[^a-zA-Z]{1})([a-z])/g,function(whole,first,second) { return (!!second) ? first+second.toUpperCase() : whole; }); }
awww yeahh
now i can format JESSICA KWOK-$WOK how i want it

money wok

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