Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validatePIN (pin) {
- let bool = true;
- let counter = 0;
- for (let i = 0; i < pin.length; i++) {
- if (Number(pin[i]) || Number(pin[i]) === 0 && pin[i] !== ' ') {
- counter++;
- }
- }
- if (counter !== pin.length) {
- bool = false;
- }
- if ((pin.length === 4 || pin.length === 6) && bool === true) {
- console.log(true);
- } else {
- console.log(false);
- }
- //return true or false
- }
- validatePIN('123');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement