dimanche 29 novembre 2020

How to write to function to check how long input from user is

I need to write function to check if my number from user prompt number and if is he 13 charachers long. My idea was to set 2 condition, but it doesn't seem to work.

var num =parseInt(prompt("Write your number"));

if( typeof(num) ==="number" && num.length ==13){
console.log("It's number 13 chars long");
}
else{
console.log("It's not number or it's not 13 chars long");
}

If i use 2 separated condiotions its work :O I dont know do that with regex cuz im am begginer :)

Aucun commentaire:

Enregistrer un commentaire