The code rejects pins with letters which it's supposed to do, but it rejects valid pins. Below is the code can you see where I went wrong.
function validatePIN (pin) {
let letters = /^[A-Za-z]+$/;
if (pin.match(letters)) {
return false;
if (pin.length = 4 || 6)
return true;
}
return false;
}
You have typo in checking the value, your if is missing a }
and your regex is checking if there is any letter at the start and finish of the pin, it should check if it has any letters
function validatePIN (pin) {
let letters = /[A-Za-z]/;
if (pin.match(letters)) {
return false;
}
if (pin.length === 4 || pin.length === 6) {
return true;
}
return false;
}