4
I need to do this exercise to create algorithm in Javascript:
"Create an algorithm to format names leaving the first letters uppercase, example Oliveira Baptist Law => Rodrigo Baptista De Oliveira"
Could someone please help me?
I can’t connect the function that formats words with the alert
.
<button onclick="myFunction()">Clique aqui pequeno Padawan para inserir o nome.</button>
<p id="demo"></p>
<script>
function myFunction() {
var x;
var idade = prompt("Digite o nome desejado Dudu");
}
String.prototype.capitalize = function(allWords) {
return (allWords) ? // if all words
this.split(' ').map(word => word.capitalize()).join(' ') :
this.charAt(0).toUpperCase() + this.slice(1);
}
</script>
Welcome to [pt.so]. A good practice to start a healthy discussion is to do the [tour] if you haven’t already done it, and read the [Ask] guide. Start by following these recommendations, especially knowing what types of questions to ask, how to create a minimal example that is complete and verifiable, and even what to do when someone answers you.
– Woss
What have you tried to do? Post your code, even if it is full of errors.
– user60252
This way: https://jsfiddle.net/56un1w9v/1/ I cannot connect the function that formats words with Alert.
– Christopher Lima