2
Hello, I’m learning the Javascript condition commands and I’m doing an exercise,: The user types a letter, the program checks whether the letter is a vowel or a consonant,so I made this code:
var letra = prompt("Digite uma letra:");
//passando variável para minúscula
letra = letra.toLowerCase();
//checando vogais
if(letra == "a" || letra == "e" || letra == "i" || letra == "o" || letra == "u"){
document.write(letra + " é uma vogal");
}
else{
document.write(letra + " é uma consoante!");
}
Only I found two problems
1.Check if it is number
For example, if the user type: 4 the result is: 4 is a consonant!
For program 4 it’s not vowel, so it’s consonant, I want to check if the string is a number and print to the user who is to type only letters
2.Check if they are other characters ex;#%*
For example, if the user type: # the result is: # is a consonant
Soon, I want to check if the string is a special character and if it is, print it out so it can type only letters
*I want to create two Else if in the program to check if the string is a number and if the string is a special character
*I’m learning Javascript and it’s an exercise with if/Else so if possible I want a solution with pure Javascript(No Jquery if possible)
Possible duplicate of Perform string checking?
– Rafael Salomão