By clicking button, I would like to have: - 1 prompt to enter my password - IF correct -> goes to a page, if not: -2nd prompt -> if correct password -> goes to a page, if not: -3rd prompt -> if correct password -> goes to page, if not:
alert('you failed')
Currently it doesen't read the 2nd prompt, nor it makes the final alert.
The code:
function passWord() {
var number = 0;
var pass1 = prompt('Give password','your password...... ');
while (number < 3) {
if (pass1=="montpellier") {
alert('Success.... you're being redirected');
window.open("quiz.php");
} else {
number =+ 1;
var pass2=prompt('Try again','paassword....');
if (pass2=="montpellier & number < 3) {
alert('Success....you'rebeing redirected');
window.open("quiz.php");
} else {
alert('You failed');
window.history.back();
}
}
}
When I try to enter the password on the second prompt, it just continues to make prompts until number < 3.