:confused:
I am suppose to write a function that uses a while loop that prompts the user for only 9 char and may not include spaces. What im doing is not even showing the prompt. Help
function Secret()
{
var secretcode = prompt("Enter Po's secret word. It must contain exactly 9 characters and there can be no empty spaces:","");
var code=secretcode.indexOf(" ");
var space==true;

while(space==false)
{
if (code.indexOf(" ")>="0")
{
space==true;
document.getElementById("results").innerHTML += (secretcode);<!--output the result of what was imputed for the secret word-->
}
if (code.indexOf(9)==/d)
{
space==false;
secretcode= prompt("Please reenter Po's secret word. It must contain exactly 9 characters and there can be no empty spaces:","");
}
else
document.getElementById("results").innerHTML += (secretcode);<!--output the result of what was imputed for the secret word-->
else
secretcode= prompt("Please reenter Po's secret word. It must contain exactly 9 characters and there can be no empty spaces:","");
}

11-09-2013, 10:00 AM

KellyS

I don't do javascript programming but I do know that you should be using a single equal sign rather than a double equal sign when assigining a value to a variable. I think it's only in an If statement that you use the equal sign.