I am trying to check whether the value in the input includes any numbers if so check whether the value includes any symbols as well. If not text.Content = "Your password should have symbols and numbers". This function runs when I click a specific button, however every time the button is clicked the live server freezes. Can you help me solving the problem and make it the code run properly. I know somewhere in the code return should be included, but I am relatively new to JS and I am not sure exactly where.
JS:
let error
for(let i = 0; i < numbers.length; i++){
if(signInPassword.value == ""){
error = "Fill in the field!"
} else if(signInPassword.value.length < 4){
error = `Your password should have at least 4 characters`
} else if(signInPassword.value.includes(numbers[i])){
for(let x = 0; x < symbols.length; i++){
if(signInPassword.value.includes(symbols[x])){
error = "matches"
} else {
error = `Your password should have symbols and numbers`
}
}
} else{
error = `Your password should have symbols and numbers`
}
pErr.textContent = error
}