Javascript Prompt Box Loops
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. <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>
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.