0
I’m trying to do an exercise where I need to validate a password, I tried this format but the conditional if
seems to ignore the second condition. I could not find the problem, which may be?
{
let senha = 'Guilhe3rme';
const regex = /[0-9]/;
if((senha.length > 5 && senha.length < 10) && (regex.test(senha) == true)){
console.log("Senha válida!")
}else{
console.log("Senha inválida!");
}
}
In the console only the "Invalid password!" comes out, if I remove the second condition the console displays the "Valid password!"
In the exercise the password must be between 5 and 10 characters long and contain at least one digit of 0-9.
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero