I started studying JS for 3 weeks and I'm really apprentice ...
My greatest doubt is that I do not know an operator or command to identify and condition the value of the type of data entered by the user, for example:
var userValue = prompt("Digite um valor numérico");
if(typeof userValue == "string"){
alert("Você precisa digitar um valor numérico para prosseguir");
return false;
}
else{
alert("Ok, vamos prosseguir");
...codigo...
}
As you can see I've used it I tried to use typeof
to identify ... in case if it is string
it will return false ...
It turns out that anything I type in prompt it interprets as string
...
It is also no use using parseInt
or +
at prompt because there it always interprets as number
the value entered ...
What could I do in this case?
Thank you in advance for your attention ^^