Hello, I want to know if there is any method in the functions to determine if the argument that I pass it, would be a text string, is made up of uppercase, lowercase or if it is made up of uppercase or lowercase. I want to make a function that tells me if the arguments I pass it, in this case a text string, and get to know if it has uppercase, lowercase or both kinds of letters. This is what has occurred to me so far, but I still have to know how I distinguish the letters (uppercase and lowercase, or both) It would be a lot, if I managed to digest how many there are of each class, since there are uppercase and lowercase letters. I only managed to make the approach. An orientation of how to proceed, or where I can look for documentation. Look at https://www.w3schools.com/js/js_function_parameters.aspand MDN but I don't know if I didn't look for it well, I didn't find a way to achieve my purpose.
function distingueLetras (argumentos) {
if (argumentos == son minusculas) {
console.log(`La palabra esta compuesta de minusculas`)
} else if(argumentos == son mayusculas){
console.log('la esta compuesta de mayusculas')
}
else {
console.log(`la palabra esta compuesta de ${x} mayusculas y ${y} minusculas`)
}
}
distingueLetras('hoy hace mucho calor')
distingueLetras('Aqui ESTAmos a 35 Grados')
distingueLetras('A LA PISCINA)
You can do this using
toLowerCase()
andtoUpperCase()
which return the string in lowercase and uppercase respectively, andcharCodeAt()
which returns the number indicating the Unicode value.And looking at the ASCII table you can see that the numbers from 65 to 90 belong to the uppercase letters of the alphabet, while from 97 to 122 belong to the lowercase letters.
For example:
This prints 97. Having that, you can iterate through
string
to get the uppercase and lowercase letters.Solution:
You can loop through the entire string (argument) and ask if it's uppercase or lowercase, then decide what to do with the result
Something like that:
I also did it for C#