0
Good morning guys All right? I am taking a beginner course in JS and I am on an issue that I can not solve at all. The question is this: "Change the previous code so that the user has 3 attempts to log in." The code that came from Alura is as follows:
`
var loginCadastrado = "alura";
var senhaCadastrada = "alura321";
var loginInformado = prompt("Informe seu login");
var senhaInformada = prompt("Informe sua senha");
if( loginCadastrado == loginInformado && senhaCadastrada == senhaInformada ) {
alert("Bem-vindo ao sistema " + loginInformado);
} else {
alert("Login inválido. Tente novamente");
}
`
The code I made is this : `
var login_cadastrado = "alura";
var senha_cadastrada = "alura123";
var login_informado = prompt("Informe o login cadastrado");
var senha_informada = prompt("Informe sua senha");
var contador = 1;
while(contador <= 3){
if(login_cadastrado == login_informado && senha_cadastrada == senha_informada){
alert("Bem vindo ao sistema " + login_informado);
break;
}
contador = contador + 1;
else{
alert("usuário ou senha incorreto");
}
</script>`
I made another version with the counter below Else but this one goes into infinite looping, does not increase the counter and I do not know how to solve. Can you help me? I’m about 4 days trying to solve and I can’t, I don’t want to look at the teacher’s code before I actually learn how to make the code.
Thanks in advance
Put at least your HTML tb in the question, it will help someone to answer you
– hugocsl