Something is wrong with this code but I can't figure out what it is. The page does not work properly or do what it's supposed to. I need a code that prompts for a password and that limits the attempts to 3. After the third attempt, it needs to have an alert box. I'm not adding what comes after the alert box yet.
<script>
var attempts = 3;
var answer = prompt("Password: ");
while (attempts != 0)
{
if (answer == "Psycho")
{
document.write("These are pictures of my kitten and her things.");
}
else
{
answer = prompt("Password: ");
attempts--;
}
}
if (attempts = 0)
{
alert("Incorrect Password");
}
</script>
Aucun commentaire:
Enregistrer un commentaire