javascript - function only accepting integers? -
i have problem function excepting integers, need accept strings valid between 2-15 characters? appreciated thanks.
function getdescription() { var description = []; description = prompt("enter description: ", ""); while (!(description >= 2 && description <= 15)) { description = prompt("error! description must between (2 - 15) characters in length.\nenter description: ", ""); } return description; } getdescription()
edit: think other problem experiencing inputting getting stored array in description?
the return value of prompt
function string, need check length of string, not value of it:
while (!(description.length >= 2 && description.length <= 15)){ // ... }
Comments
Post a Comment