Skip to content

Instantly share code, notes, and snippets.

@jorgejr568
Created January 25, 2018 11:41
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 jorgejr568/e708ca535e0db3d15d600f1f7112284f to your computer and use it in GitHub Desktop.
Save jorgejr568/e708ca535e0db3d15d600f1f7112284f to your computer and use it in GitHub Desktop.
Watcher for name format
window.nameParse = function(name){
let nameExploded = val
.split(' ')
.filter(function (v) {
return v.trim().length > 0;
});
nameExploded=nameExploded.map(function (val) {
if(
([
"de",
"do",
"da",
"di",
"du"
]).includes(val)
) return val.toLowerCase();
else {
let subNameExploded = val
.split("'")
.filter(function (v) {
return v.trim().length > 0;
});
subNameExploded=subNameExploded.map(function(word){
return word.charAt(0).toUpperCase()+word.slice(1).toLowerCase();
});
return subNameExploded.join("'");
}
});
return nameExploded.join(' ');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment