Created
January 25, 2018 11:41
-
-
Save jorgejr568/e708ca535e0db3d15d600f1f7112284f to your computer and use it in GitHub Desktop.
Watcher for name format
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
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