Codewars 7 kyu Regex Validate PIN Code JavaScript

preview_player
Показать описание
this one is about the test() method, regex, and more

Рекомендации по теме
Комментарии
Автор

Hi there. I'm back :)

Thanks for the code.

Please can you kindly tell me why my code isn't working? I'm literally pulling my hair out now as I can't for the life of me fathom why.

I did

Function validatePIN (pin) {
if (pin.length != 4 && 6 && pin % 2 != 0 || 1) {
return false;
}

For (let n of pin) {
if (pin[n] > '9' && pin[n] < '0') {
return false;
}
}
return true;
}

But it's not working. I passed the
a. return False for pins with lengths other than 4 or 6 and
b. return False for pins which contain characters other than digits.

But then it fails on the last criteria which is to return True for valid pins.

Any idea why? Kindly help me look through my code.

Chacha
visit shbcf.ru