Missing a final } at the very end of the code, to close the
for loop.
And the message "You've used up all your attempts." will *NEVER* be seen.
That's because it is only seen (a) INSIDE the
for loop and (b) when
i is 2 or greater. But
i can never be 2 or greater inside that loop, by the very terms of how the
for is written.
Try again?
Code:
var user_name, password, passed = false;
for(var i=1; i<= 3 && passed == false; i++)
{
user_name = prompt ("Please enter your username: ");
password = prompt ("Please enter your password: ");
passed = ( (user_name=="John123") && (password= "helloworld") );
} // end of loop after 3 tries *OR* if passed is true!
if ( passed )
{
alert("Welcome, " + user_name + ".");
} else {
location.href = "http://www.google.com";
}