i have a problem with this function only excepting integers, i need it to only accept strings that are valid between 2-15 characters?
any help is appreciated thanks.
function getDescription() {
var Description = [];
Description = prompt("Enter the description: ", "");
while (!(Description >= 2 && Description <= 15))
{
Description = prompt("Error! The description must be between (2 - 15) characters in length.\nEnter the description: ", "");
}
return Description;
}
getDescription()
edit: I think the other problem i am experiencing is what i am inputting is it actually getting stored as an array in Description?
The return value of the
promptfunction is a string, so you need to check the length of that string, not the value of it: