Last active
January 13, 2016 20:37
-
-
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
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
/* 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]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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